diff --git a/pkg/console/controllers/healthcheck/controller.go b/pkg/console/controllers/healthcheck/controller.go index 0f63cf506..3f34a9d8f 100644 --- a/pkg/console/controllers/healthcheck/controller.go +++ b/pkg/console/controllers/healthcheck/controller.go @@ -18,7 +18,7 @@ import ( "k8s.io/klog/v2" // openshift - configv1 "github.com/openshift/api/config/v1" + operatorsv1 "github.com/openshift/api/operator/v1" routev1 "github.com/openshift/api/route/v1" configclientv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" @@ -48,6 +48,7 @@ type HealthCheckController struct { routeLister routev1listers.RouteLister ingressConfigLister configlistersv1.IngressLister operatorConfigLister operatorv1listers.ConsoleLister + clusterVersionLister configlistersv1.ClusterVersionLister } func NewHealthCheckController( @@ -68,6 +69,7 @@ func NewHealthCheckController( operatorConfigLister: operatorConfigInformer.Lister(), infrastructureConfigLister: configInformer.Config().V1().Infrastructures().Lister(), ingressConfigLister: configInformer.Config().V1().Ingresses().Lister(), + clusterVersionLister: configInformer.Config().V1().ClusterVersions().Lister(), routeLister: routeInformer.Lister(), configMapLister: coreInformer.ConfigMaps().Lister(), } @@ -122,10 +124,14 @@ func (c *HealthCheckController) Sync(ctx context.Context, controllerContext fact klog.Errorf("infrastructure config error: %v", err) return statusHandler.FlushAndReturn(err) } + clusterVersionConfig, err := c.clusterVersionLister.Get("version") + if err != nil { + return statusHandler.FlushAndReturn(err) + } // Disable the health check for external control plane topology (hypershift) and ingress NLB. // This is to avoid an issue with internal NLB see https://issues.redhat.com/browse/OCPBUGS-23300 - if isExternalControlPlaneWithNLB(infrastructureConfig, ingressConfig) { + if util.IsExternalControlPlaneWithNLB(infrastructureConfig, ingressConfig) || util.IsExternalControlPlaneWithIngressDisabled(infrastructureConfig, clusterVersionConfig) { return nil } @@ -259,13 +265,6 @@ func clientWithCA(caPool *x509.CertPool) *http.Client { } } -func isExternalControlPlaneWithNLB(infrastructureConfig *configv1.Infrastructure, ingressConfig *configv1.Ingress) bool { - return infrastructureConfig.Status.ControlPlaneTopology == configv1.ExternalTopologyMode && - infrastructureConfig.Status.PlatformStatus.Type == configv1.AWSPlatformType && - ingressConfig.Spec.LoadBalancer.Platform.Type == configv1.AWSPlatformType && - ingressConfig.Spec.LoadBalancer.Platform.AWS.Type == configv1.NLB -} - func logHealthCheckError(errStr string) { klog.V(4).Infof("health check error: %v; Retry...", errStr) } diff --git a/pkg/console/controllers/healthcheck/controller_test.go b/pkg/console/controllers/healthcheck/controller_test.go index 2def2957c..d100a0883 100644 --- a/pkg/console/controllers/healthcheck/controller_test.go +++ b/pkg/console/controllers/healthcheck/controller_test.go @@ -5,6 +5,7 @@ import ( "github.com/go-test/deep" configv1 "github.com/openshift/api/config/v1" + "github.com/openshift/console-operator/pkg/console/controllers/util" ) func TestGetPlatformURL(t *testing.T) { @@ -94,7 +95,7 @@ func TestGetPlatformURL(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if diff := deep.Equal(isExternalControlPlaneWithNLB(tt.args.infrastructureConfig, tt.args.ingressConfig), tt.want); diff != nil { + if diff := deep.Equal(util.IsExternalControlPlaneWithNLB(tt.args.infrastructureConfig, tt.args.ingressConfig), tt.want); diff != nil { t.Error(diff) } }) diff --git a/pkg/console/controllers/oauthclients/oauthclients.go b/pkg/console/controllers/oauthclients/oauthclients.go index 1c8f9d63b..dbe5721d3 100644 --- a/pkg/console/controllers/oauthclients/oauthclients.go +++ b/pkg/console/controllers/oauthclients/oauthclients.go @@ -16,6 +16,7 @@ import ( configv1 "github.com/openshift/api/config/v1" operatorv1 "github.com/openshift/api/operator/v1" + configinformer "github.com/openshift/client-go/config/informers/externalversions" configv1informers "github.com/openshift/client-go/config/informers/externalversions/config/v1" configv1lister "github.com/openshift/client-go/config/listers/config/v1" oauthclient "github.com/openshift/client-go/oauth/clientset/versioned" @@ -56,6 +57,8 @@ type oauthClientsController struct { routesLister routev1listers.RouteLister ingressConfigLister configv1lister.IngressLister targetNSSecretsLister corev1listers.SecretLister + infrastructureConfigLister configv1lister.InfrastructureLister + clusterVersionLister configv1lister.ClusterVersionLister } func NewOAuthClientsController( @@ -66,6 +69,7 @@ func NewOAuthClientsController( routeInformer routev1informers.RouteInformer, ingressConfigInformer configv1informers.IngressInformer, targetNSsecretsInformer corev1informers.SecretInformer, + configInformer configinformer.SharedInformerFactory, oauthClientSwitchedInformer *util.InformerWithSwitch, recorder events.Recorder, ) factory.Controller { @@ -79,6 +83,8 @@ func NewOAuthClientsController( consoleOperatorLister: consoleOperatorInformer.Lister(), routesLister: routeInformer.Lister(), ingressConfigLister: ingressConfigInformer.Lister(), + infrastructureConfigLister: configInformer.Config().V1().Infrastructures().Lister(), + clusterVersionLister: configInformer.Config().V1().ClusterVersions().Lister(), targetNSSecretsLister: targetNSsecretsInformer.Lister(), } @@ -109,6 +115,20 @@ func (c *oauthClientsController) sync(ctx context.Context, controllerContext fac statusHandler := status.NewStatusHandler(c.operatorClient) + infrastructureConfig, err := c.infrastructureConfigLister.Get(api.ConfigResourceName) + if err != nil { + return statusHandler.FlushAndReturn(err) + } + + clusterVersionConfig, err := c.clusterVersionLister.Get("version") + if err != nil { + return statusHandler.FlushAndReturn(err) + } + + if util.IsExternalControlPlaneWithIngressDisabled(infrastructureConfig, clusterVersionConfig) { + return statusHandler.FlushAndReturn(nil) + } + authnConfig, err := c.authnLister.Get(api.ConfigResourceName) if err != nil { return err diff --git a/pkg/console/controllers/route/controller.go b/pkg/console/controllers/route/controller.go index 438e44d17..7ec25fc35 100644 --- a/pkg/console/controllers/route/controller.go +++ b/pkg/console/controllers/route/controller.go @@ -142,11 +142,6 @@ func (c *RouteSyncController) Sync(ctx context.Context, controllerContext factor return statusHandler.FlushAndReturn(err) } - ingressControllerConfig, err := c.ingressControllerLister.IngressControllers(api.IngressControllerNamespace).Get(api.DefaultIngressController) - if err != nil { - return statusHandler.FlushAndReturn(err) - } - clusterVersionConfig, err := c.clusterVersionLister.Get("version") if err != nil { return statusHandler.FlushAndReturn(err) @@ -159,6 +154,11 @@ func (c *RouteSyncController) Sync(ctx context.Context, controllerContext factor return statusHandler.FlushAndReturn(nil) } + ingressControllerConfig, err := c.ingressControllerLister.IngressControllers(api.IngressControllerNamespace).Get(api.DefaultIngressController) + if err != nil { + return statusHandler.FlushAndReturn(err) + } + ingressConfig, err := c.ingressConfigLister.Get(api.ConfigResourceName) if err != nil { return statusHandler.FlushAndReturn(err) diff --git a/pkg/console/controllers/util/util.go b/pkg/console/controllers/util/util.go index 968f66dc6..457efc0bd 100644 --- a/pkg/console/controllers/util/util.go +++ b/pkg/console/controllers/util/util.go @@ -98,3 +98,11 @@ func IsExternalControlPlaneWithIngressDisabled(infrastructureConfig *configv1.In return infrastructureConfig.Status.ControlPlaneTopology == configv1.ExternalTopologyMode && !isIngressCapabilityEnabled } + +// IsExternalControlPlaneWithNLB returns true if the cluster is in external control plane topology (hypershift) +func IsExternalControlPlaneWithNLB(infrastructureConfig *configv1.Infrastructure, ingressConfig *configv1.Ingress) bool { + return infrastructureConfig.Status.ControlPlaneTopology == configv1.ExternalTopologyMode && + infrastructureConfig.Status.PlatformStatus.Type == configv1.AWSPlatformType && + ingressConfig.Spec.LoadBalancer.Platform.Type == configv1.AWSPlatformType && + ingressConfig.Spec.LoadBalancer.Platform.AWS.Type == configv1.NLB +} diff --git a/pkg/console/starter/starter.go b/pkg/console/starter/starter.go index de2b81f38..4d85bf9cb 100644 --- a/pkg/console/starter/starter.go +++ b/pkg/console/starter/starter.go @@ -272,6 +272,7 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle routesInformersNamespaced.Route().V1().Routes(), configInformers.Config().V1().Ingresses(), kubeInformersNamespaced.Core().V1().Secrets(), + configInformers, oauthClientsSwitchedInformer, recorder, )