Skip to content

Commit 68c1a4d

Browse files
Merge pull request #847 from stlaz/oauthclients_schema
CONSOLE-3912: OAuthClients: only add `oidcClients` to authentication status if the field exists
2 parents 3682ec8 + b30f7ce commit 68c1a4d

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

pkg/console/controllers/oauthclients/oauthclients.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type oauthClientsController struct {
6161
configNSSecretsLister corev1listers.SecretLister
6262
targetNSDeploymentsLister appsv1listers.DeploymentLister
6363
targetNSConfigLister corev1listers.ConfigMapLister
64-
featureGatesLister configv1lister.FeatureGateLister
6564

6665
authStatusHandler status.AuthStatusHandler
6766
}
@@ -81,7 +80,6 @@ func NewOAuthClientsController(
8180
targetNSConfigInformer corev1informers.ConfigMapInformer,
8281
targetNSDeploymentsInformer appsv1informers.DeploymentInformer,
8382
oauthClientSwitchedInformer *util.InformerWithSwitch,
84-
featureGatesInformer configv1informers.FeatureGateInformer,
8583
recorder events.Recorder,
8684
) factory.Controller {
8785
c := oauthClientsController{
@@ -100,7 +98,6 @@ func NewOAuthClientsController(
10098
configNSSecretsLister: configNSSecretsInformer.Lister(),
10199
targetNSConfigLister: targetNSConfigInformer.Lister(),
102100
targetNSDeploymentsLister: targetNSDeploymentsInformer.Lister(),
103-
featureGatesLister: featureGatesInformer.Lister(),
104101

105102
authStatusHandler: status.NewAuthStatusHandler(authentication, api.OpenShiftConsoleName, api.TargetNamespace, api.OpenShiftConsoleOperator),
106103
}
@@ -149,11 +146,6 @@ func (c *oauthClientsController) sync(ctx context.Context, controllerContext fac
149146
return err
150147
}
151148

152-
featureGates, err := c.featureGatesLister.Get(api.ConfigResourceName)
153-
if err != nil {
154-
return err
155-
}
156-
157149
routeName := api.OpenShiftConsoleRouteName
158150
routeConfig := routesub.NewRouteConfig(operatorConfig, ingressConfig, routeName)
159151
if routeConfig.IsCustomHostnameSet() {
@@ -191,11 +183,18 @@ func (c *oauthClientsController) sync(ctx context.Context, controllerContext fac
191183

192184
case configv1.AuthenticationTypeOIDC:
193185
syncErr = c.syncAuthTypeOIDC(ctx, controllerContext, statusHandler, operatorConfig, authnConfig)
194-
}
186+
if syncErr != nil {
187+
break
188+
}
195189

196-
// AuthStatusHandler manages fields that are behind the CustomNoUpgrade and TechPreviewNoUpgrade featuregate sets
197-
// call Apply() only if they are enabled, otherwise server-side apply will complain
198-
if featureGates.Spec.FeatureSet == configv1.TechPreviewNoUpgrade || featureGates.Spec.FeatureSet == configv1.CustomNoUpgrade {
190+
// FIXME: once we're able to distinguish featuregates for HCP (on by default)
191+
// and OCP (currently only in TechPreview), move this outside of the switch.
192+
// If you don't, GitOps people will give you a lot of hate - the API validation
193+
// does not allow setting the OIDC providers' client in the provider if it
194+
// doesn't already appear in the status, which is what the following does.
195+
// This means that you cannot get to the desired state in a single update
196+
// as you first need to set the Authn type to OIDC, wait for the operator to
197+
// set the client, and only then you can configure the client in the provider.
199198
if err := c.authStatusHandler.Apply(ctx, authnConfig); err != nil {
200199
statusHandler.AddConditions(status.HandleProgressingOrDegraded("AuthStatusHandler", "FailedApply", err))
201200
return statusHandler.FlushAndReturn(err)

pkg/console/starter/starter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
217217
kubeInformersNamespaced.Core().V1().ConfigMaps(),
218218
kubeInformersNamespaced.Apps().V1().Deployments(),
219219
oauthClientsSwitchedInformer,
220-
configInformers.Config().V1().FeatureGates(),
221220
recorder,
222221
)
223222

0 commit comments

Comments
 (0)