Skip to content

Commit a418b49

Browse files
committed
oidcsetup: don't block any status updates on errors
1 parent 3637454 commit a418b49

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

pkg/console/controllers/oidcsetup/oidcsetup.go

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ func (c *oidcSetupController) sync(ctx context.Context, syncCtx factory.SyncCont
9595
return nil
9696
}
9797

98+
oidcClientsSchema, err := authnConfigHasOIDCFields(c.crdLister)
99+
if err != nil {
100+
return statusHandler.FlushAndReturn(err)
101+
}
102+
103+
// the schema is feature-gating this controller, we assume API validation won't
104+
// allow authentication/cluster 'Type=OIDC' if the `.status.oidcClients` field
105+
// does not exist
106+
if !oidcClientsSchema {
107+
// reset all conditions set by this controller
108+
statusHandler.AddConditions(status.HandleProgressingOrDegraded("OIDCClientConfig", "", nil))
109+
statusHandler.AddConditions(status.HandleProgressingOrDegraded("AuthStatusHandler", "", nil))
110+
return statusHandler.FlushAndReturn(nil)
111+
}
112+
98113
operatorConfig, err := c.consoleOperatorLister.Get(api.ConfigResourceName)
99114
if err != nil {
100115
return err
@@ -105,29 +120,31 @@ func (c *oidcSetupController) sync(ctx context.Context, syncCtx factory.SyncCont
105120
return err
106121
}
107122

123+
// we need to keep track of errors during the sync so that we can requeue
124+
// if any occur
125+
var errs []error
108126
if authnConfig.Spec.Type == configv1.AuthenticationTypeOIDC {
109-
err = c.syncAuthTypeOIDC(ctx, syncCtx, statusHandler, operatorConfig, authnConfig)
110-
statusHandler.AddConditions(status.HandleProgressingOrDegraded("OIDCClientConfig", "MissingID", err))
111-
if err != nil {
112-
return statusHandler.FlushAndReturn(err)
127+
syncErr := c.syncAuthTypeOIDC(ctx, syncCtx, statusHandler, operatorConfig, authnConfig)
128+
statusHandler.AddConditions(
129+
status.HandleProgressingOrDegraded(
130+
"OIDCClientConfig", "OIDCConfigSyncFailed",
131+
syncErr,
132+
),
133+
)
134+
if syncErr != nil {
135+
errs = append(errs, syncErr)
113136
}
114-
} else {
115-
statusHandler.AddConditions(status.HandleProgressingOrDegraded("OIDCClientConfig", "", nil))
116137
}
117138

118-
oidcClientsSchema, err := authnConfigHasOIDCFields(c.crdLister)
119-
if err != nil {
120-
return statusHandler.FlushAndReturn(err)
139+
applyErr := c.authStatusHandler.Apply(ctx, authnConfig)
140+
statusHandler.AddConditions(status.HandleProgressingOrDegraded("AuthStatusHandler", "FailedApply", applyErr))
141+
if applyErr != nil {
142+
errs = append(errs, applyErr)
121143
}
122144

123-
if oidcClientsSchema {
124-
applyErr := c.authStatusHandler.Apply(ctx, authnConfig)
125-
statusHandler.AddConditions(status.HandleProgressingOrDegraded("AuthStatusHandler", "FailedApply", applyErr))
126-
if applyErr != nil {
127-
return statusHandler.FlushAndReturn(applyErr)
128-
}
145+
if len(errs) > 0 {
146+
return statusHandler.FlushAndReturn(factory.SyntheticRequeueError)
129147
}
130-
131148
return statusHandler.FlushAndReturn(nil)
132149
}
133150

0 commit comments

Comments
 (0)