@@ -95,6 +95,21 @@ func (c *oidcSetupController) sync(ctx context.Context, syncCtx factory.SyncCont
95
95
return nil
96
96
}
97
97
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
+
98
113
operatorConfig , err := c .consoleOperatorLister .Get (api .ConfigResourceName )
99
114
if err != nil {
100
115
return err
@@ -105,29 +120,31 @@ func (c *oidcSetupController) sync(ctx context.Context, syncCtx factory.SyncCont
105
120
return err
106
121
}
107
122
123
+ // we need to keep track of errors during the sync so that we can requeue
124
+ // if any occur
125
+ var errs []error
108
126
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 )
113
136
}
114
- } else {
115
- statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OIDCClientConfig" , "" , nil ))
116
137
}
117
138
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 )
121
143
}
122
144
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 )
129
147
}
130
-
131
148
return statusHandler .FlushAndReturn (nil )
132
149
}
133
150
0 commit comments