diff --git a/build/run-functional-tests.sh b/build/run-functional-tests.sh index 7ec9cc73c..fca3f727d 100755 --- a/build/run-functional-tests.sh +++ b/build/run-functional-tests.sh @@ -14,7 +14,7 @@ mkdir -p $TEST_RESULT_DIR function init_hub() { echo "init_hub 1st parameter: "$1 >&2 - local _CMDINITRESULT=`clusteradm init $1 --image-registry=quay.io/open-cluster-management --tag=v0.5.0` + local _CMDINITRESULT=`clusteradm init $1 --image-registry=quay.io/open-cluster-management --tag=latest` if [ $? != 0 ] then ERROR_REPORT=$ERROR_REPORT+"clusteradm init failed\n" @@ -29,7 +29,7 @@ function join_hub() { echo "join_hub 4nd parameter: "$4 >&2 local _CMDJOIN=`echo "$1" | cut -d ':' -f2-4 | cut -d '<' -f1` _CMDJOIN="$_CMDJOIN $2 $3 $4" - local _CMDJOINRESULT=`$_CMDJOIN --wait` + local _CMDJOINRESULT=`$_CMDJOIN --wait --force-internal-endpoint-lookup` if [ $? != 0 ] then ERROR_REPORT=$ERROR_REPORT+"clusteradm join failed\n" diff --git a/pkg/cmd/join/cmd.go b/pkg/cmd/join/cmd.go index 2dcc9c1b7..b9bb6867e 100644 --- a/pkg/cmd/join/cmd.go +++ b/pkg/cmd/join/cmd.go @@ -50,10 +50,9 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream cmd.Flags().StringVar(&o.registry, "image-registry", "quay.io/open-cluster-management", "The name of the image registry serving OCM images.") cmd.Flags().StringVar(&o.version, "version", "latest", "The installing version of OCM components.") - cmd.Flags().BoolVar(&o.skipHubInClusterEndpointLookup, "skip-internal-endpoint-lookup", false, - "If true, the installed klusterlet agent will be starting registration using the external endpoint "+ - "from --hub-apiserver instead of looking for the internal endpoint from the public cluster-info in the hub "+ - "cluster.") + cmd.Flags().BoolVar(&o.forceHubInClusterEndpointLookup, "force-internal-endpoint-lookup", false, + "If true, the installed klusterlet agent will be starting the cluster registration process by "+ + "looking for the internal endpoint from the public cluster-info in the hub cluster instead of from --hub-apiserver.") cmd.Flags().BoolVar(&o.wait, "wait", false, "If true, running the cluster registration in foreground.") return cmd } diff --git a/pkg/cmd/join/exec.go b/pkg/cmd/join/exec.go index 810c605c9..674f140e6 100644 --- a/pkg/cmd/join/exec.go +++ b/pkg/cmd/join/exec.go @@ -340,21 +340,20 @@ func (o *Options) createKubeConfig(externalClientUnSecure *kubernetes.Clientset, return "", err } - hubAPIServerInternal, err := helpers.GetAPIServer(externalClientUnSecure) - if err != nil { - if errors.IsNotFound(err) { - hubAPIServerInternal = o.hubAPIServer - } else { - return "", err + hubApiserver := o.hubAPIServer + if o.forceHubInClusterEndpointLookup || len(hubApiserver) == 0 { + hubApiserver, err = helpers.GetAPIServer(externalClientUnSecure) + if err != nil { + if !errors.IsNotFound(err) { + return "", err + } } } bootstrapConfig := bootstrapExternalConfigUnSecure.DeepCopy() bootstrapConfig.Clusters[0].Cluster.InsecureSkipTLSVerify = false bootstrapConfig.Clusters[0].Cluster.CertificateAuthorityData = ca - if !o.skipHubInClusterEndpointLookup { - bootstrapConfig.Clusters[0].Cluster.Server = hubAPIServerInternal - } + bootstrapConfig.Clusters[0].Cluster.Server = hubApiserver bootstrapConfigBytes, err := yaml.Marshal(bootstrapConfig) if err != nil { return "", err diff --git a/pkg/cmd/join/options.go b/pkg/cmd/join/options.go index 46963376c..f19ac349c 100644 --- a/pkg/cmd/join/options.go +++ b/pkg/cmd/join/options.go @@ -28,10 +28,10 @@ type Options struct { //Runs the cluster joining in foreground wait bool - // The installing registration agent will be starting registration using - // the external endpoint from --hub-apiserver instead of looking for the - // internal endpoint from the public cluster-info. - skipHubInClusterEndpointLookup bool + // By default, The installing registration agent will be starting registration using + // the external endpoint from --hub-apiserver instead of looking for the internal + // endpoint from the public cluster-info. + forceHubInClusterEndpointLookup bool } //Values: The values used in the template