Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions pkg/console/controllers/healthcheck/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -48,6 +48,7 @@ type HealthCheckController struct {
routeLister routev1listers.RouteLister
ingressConfigLister configlistersv1.IngressLister
operatorConfigLister operatorv1listers.ConsoleLister
clusterVersionLister configlistersv1.ClusterVersionLister
}

func NewHealthCheckController(
Expand All @@ -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(),
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion pkg/console/controllers/healthcheck/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
})
Expand Down
20 changes: 20 additions & 0 deletions pkg/console/controllers/oauthclients/oauthclients.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -56,6 +57,8 @@ type oauthClientsController struct {
routesLister routev1listers.RouteLister
ingressConfigLister configv1lister.IngressLister
targetNSSecretsLister corev1listers.SecretLister
infrastructureConfigLister configv1lister.InfrastructureLister
clusterVersionLister configv1lister.ClusterVersionLister
}

func NewOAuthClientsController(
Expand All @@ -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 {
Expand All @@ -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(),
}

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pkg/console/controllers/route/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions pkg/console/controllers/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions pkg/console/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down