Skip to content

Commit 82d1922

Browse files
committed
fix(disruption): Using correct internal LB monitor on ARO Hypershift
The internal load balancer monitor used default LB config for ARO Hypershift is not applicable to Hypershift clusters and causes test failures. This change uses internal LB with specific settings(7743 port) to the deployment of the internal LB monitor on ARO Hypershift.
1 parent 69ff479 commit 82d1922

File tree

1 file changed

+47
-16
lines changed
  • pkg/monitortests/kubeapiserver/disruptioninclusterapiserver

1 file changed

+47
-16
lines changed

pkg/monitortests/kubeapiserver/disruptioninclusterapiserver/monitortest.go

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ type InvariantInClusterDisruption struct {
7575
replicas int32
7676
controlPlaneNodes int32
7777

78+
isHypershift bool
79+
isAROHCPCluster bool
80+
7881
adminRESTConfig *rest.Config
7982
kubeClient kubernetes.Interface
8083
}
@@ -113,7 +116,7 @@ func (i *InvariantInClusterDisruption) createDeploymentAndWaitToRollout(ctx cont
113116
return nil
114117
}
115118

116-
func (i *InvariantInClusterDisruption) createInternalLBDeployment(ctx context.Context, apiIntHost string) error {
119+
func (i *InvariantInClusterDisruption) createInternalLBDeployment(ctx context.Context, apiIntHost, apiIntPort string) error {
117120
deploymentObj := resourceread.ReadDeploymentV1OrDie(internalLBDeploymentYaml)
118121
deploymentObj.SetNamespace(i.namespaceName)
119122
deploymentObj.Spec.Template.Spec.Containers[0].Env[0].Value = apiIntHost
@@ -122,6 +125,18 @@ func (i *InvariantInClusterDisruption) createInternalLBDeployment(ctx context.Co
122125
// we need to use the openshift-tests image of the destination during an upgrade.
123126
deploymentObj.Spec.Template.Spec.Containers[0].Image = i.openshiftTestsImagePullSpec
124127

128+
// Set the correct port for internal API server
129+
for j, env := range deploymentObj.Spec.Template.Spec.Containers[0].Env {
130+
if env.Name == "KUBERNETES_SERVICE_PORT" {
131+
if i.isHypershift && i.isAROHCPCluster {
132+
deploymentObj.Spec.Template.Spec.Containers[0].Env[j].Value = "7443"
133+
} else {
134+
deploymentObj.Spec.Template.Spec.Containers[0].Env[j].Value = apiIntPort
135+
}
136+
break
137+
}
138+
}
139+
125140
err := i.createDeploymentAndWaitToRollout(ctx, deploymentObj)
126141
if err != nil {
127142
return err
@@ -304,25 +319,21 @@ func (i *InvariantInClusterDisruption) StartCollection(ctx context.Context, admi
304319
var err error
305320
log := logrus.WithField("monitorTest", "apiserver-incluster-availability").WithField("namespace", i.namespaceName).WithField("func", "StartCollection")
306321

307-
// Check for ARO HCP and skip if detected
322+
// Check for Hypershift and ARO HCP
308323
oc := exutil.NewCLI("apiserver-incluster-availability").AsAdmin()
309-
var isAROHCPcluster bool
310-
isHypershift, _ := exutil.IsHypershift(ctx, oc.AdminConfigClient())
311-
if isHypershift {
324+
i.isHypershift, _ = exutil.IsHypershift(ctx, oc.AdminConfigClient())
325+
if i.isHypershift {
312326
_, hcpNamespace, err := exutil.GetHypershiftManagementClusterConfigAndNamespace()
313327
if err != nil {
314328
logrus.WithError(err).Error("failed to get hypershift management cluster config and namespace")
315329
return err
316330
}
317331

318-
// For Hypershift, only skip if it's specifically ARO HCP
319-
// Use management cluster client to check the control-plane-operator deployment
320332
managementOC := exutil.NewHypershiftManagementCLI(hcpNamespace)
321-
if isAROHCPcluster, err = exutil.IsAroHCP(ctx, hcpNamespace, managementOC.AdminKubeClient()); err != nil {
333+
i.isAROHCPCluster, err = exutil.IsAroHCP(ctx, hcpNamespace, managementOC.AdminKubeClient())
334+
if err != nil {
322335
logrus.WithError(err).Warning("Failed to check if ARO HCP, assuming it's not")
323-
} else if isAROHCPcluster {
324-
i.notSupportedReason = "platform Hypershift - ARO HCP not supported"
325-
return nil
336+
i.isAROHCPCluster = false // Assume not ARO HCP on error
326337
}
327338
}
328339

@@ -378,11 +389,31 @@ func (i *InvariantInClusterDisruption) StartCollection(ctx context.Context, admi
378389
return fmt.Errorf("error getting openshift infrastructure: %v", err)
379390
}
380391

381-
internalAPI, err := url.Parse(infra.Status.APIServerInternalURL)
382-
if err != nil {
383-
return fmt.Errorf("error parsing api int url: %v", err)
392+
var apiIntHost string
393+
var apiIntPort string
394+
if i.isHypershift {
395+
parsedURL, err := url.Parse(i.adminRESTConfig.Host)
396+
if err != nil {
397+
return fmt.Errorf("failed to parse adminRESTConfig.Host %q: %v", i.adminRESTConfig.Host, err)
398+
}
399+
apiIntHost = parsedURL.Hostname()
400+
if parsedURL.Port() != "" {
401+
apiIntPort = parsedURL.Port()
402+
} else {
403+
apiIntPort = "6443" // default port
404+
}
405+
} else {
406+
internalAPI, err := url.Parse(infra.Status.APIServerInternalURL)
407+
if err != nil {
408+
return fmt.Errorf("error parsing api int url: %v", err)
409+
}
410+
apiIntHost = internalAPI.Hostname()
411+
if internalAPI.Port() != "" {
412+
apiIntPort = internalAPI.Port()
413+
} else {
414+
apiIntPort = "6443" // default port
415+
}
384416
}
385-
apiIntHost := internalAPI.Hostname()
386417

387418
allNodes, err := i.kubeClient.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
388419
if err != nil {
@@ -438,7 +469,7 @@ func (i *InvariantInClusterDisruption) StartCollection(ctx context.Context, admi
438469
if err != nil {
439470
return fmt.Errorf("error creating localhost: %v", err)
440471
}
441-
err = i.createInternalLBDeployment(ctx, apiIntHost)
472+
err = i.createInternalLBDeployment(ctx, apiIntHost, apiIntPort)
442473
if err != nil {
443474
return fmt.Errorf("error creating internal LB: %v", err)
444475
}

0 commit comments

Comments
 (0)