@@ -175,6 +175,7 @@ type Operator struct {
175
175
exclude string
176
176
177
177
enabledFeatureGates featuregates.CvoGateChecker
178
+ requiredFeatureSet configv1.FeatureSet
178
179
179
180
clusterProfile string
180
181
uid types.UID
@@ -210,6 +211,8 @@ func New(
210
211
injectClusterIdIntoPromQL bool ,
211
212
updateService string ,
212
213
alwaysEnableCapabilities []configv1.ClusterVersionCapability ,
214
+ startingFeatureSet configv1.FeatureSet ,
215
+ cvoGates featuregates.CvoGateChecker ,
213
216
) (* Operator , error ) {
214
217
eventBroadcaster := record .NewBroadcaster ()
215
218
eventBroadcaster .StartLogging (klog .Infof )
@@ -246,7 +249,9 @@ func New(
246
249
// Because of OCPBUGS-30080, we can only detect the enabled feature gates after Operator loads the initial payload
247
250
// from disk via LoadInitialPayload. We must not have any gate-checking code until that happens, so we initialize
248
251
// this field with a checker that panics when used.
249
- enabledFeatureGates : featuregates .PanicOnUsageBeforeInitialization ,
252
+ enabledFeatureGates : cvoGates ,
253
+ requiredFeatureSet : startingFeatureSet ,
254
+
250
255
alwaysEnableCapabilities : alwaysEnableCapabilities ,
251
256
}
252
257
@@ -283,7 +288,7 @@ func New(
283
288
284
289
// LoadInitialPayload waits until a ClusterVersion object exists. It then retrieves the payload contents, verifies the
285
290
// initial state and returns it. If the payload is invalid, an error is returned.
286
- func (optr * Operator ) LoadInitialPayload (ctx context.Context , startingRequiredFeatureSet configv1. FeatureSet , restConfig * rest.Config ) ( * payload. Update , error ) {
291
+ func (optr * Operator ) LoadInitialPayload (ctx context.Context , restConfig , burstRestConfig * rest.Config ) error {
287
292
288
293
// wait until cluster version object exists
289
294
if err := wait .PollUntilContextCancel (ctx , 3 * time .Second , true , func (ctx context.Context ) (bool , error ) {
@@ -300,19 +305,19 @@ func (optr *Operator) LoadInitialPayload(ctx context.Context, startingRequiredFe
300
305
}
301
306
return true , nil
302
307
}); err != nil {
303
- return nil , fmt .Errorf ("Error when attempting to get cluster version object: %w" , err )
308
+ return fmt .Errorf ("Error when attempting to get cluster version object: %w" , err )
304
309
}
305
310
306
- update , err := payload .LoadUpdate (optr .defaultPayloadDir (), optr .release .Image , optr .exclude , string (startingRequiredFeatureSet ),
311
+ update , err := payload .LoadUpdate (optr .defaultPayloadDir (), optr .release .Image , optr .exclude , string (optr . requiredFeatureSet ),
307
312
optr .clusterProfile , configv1 .KnownClusterVersionCapabilities )
308
313
309
314
if err != nil {
310
- return nil , fmt .Errorf ("the local release contents are invalid - no current version can be determined from disk: %v" , err )
315
+ return fmt .Errorf ("the local release contents are invalid - no current version can be determined from disk: %v" , err )
311
316
}
312
317
httpClientConstructor := sigstore .NewCachedHTTPClientConstructor (optr .HTTPClient , nil )
313
318
configClient , err := coreclientsetv1 .NewForConfig (restConfig )
314
319
if err != nil {
315
- return nil , fmt .Errorf ("unable to create a configuration client: %v" , err )
320
+ return fmt .Errorf ("unable to create a configuration client: %v" , err )
316
321
}
317
322
318
323
customSignatureStore := & customsignaturestore.Store {
@@ -324,7 +329,7 @@ func (optr *Operator) LoadInitialPayload(ctx context.Context, startingRequiredFe
324
329
// attempt to load a verifier as defined in the payload
325
330
verifier , signatureStore , err := loadConfigMapVerifierDataFromUpdate (update , httpClientConstructor .HTTPClient , configClient , customSignatureStore )
326
331
if err != nil {
327
- return nil , err
332
+ return err
328
333
}
329
334
if verifier != nil {
330
335
klog .Infof ("Verifying release authenticity: %v" , verifier )
@@ -334,13 +339,6 @@ func (optr *Operator) LoadInitialPayload(ctx context.Context, startingRequiredFe
334
339
}
335
340
optr .verifier = verifier
336
341
optr .signatureStore = signatureStore
337
- return update , nil
338
- }
339
-
340
- // InitializeFromPayload configures the controller that loads and applies content to the cluster given an initial payload
341
- // and feature gate data.
342
- func (optr * Operator ) InitializeFromPayload (update * payload.Update , requiredFeatureSet configv1.FeatureSet , cvoFlags featuregates.CvoGateChecker , restConfig * rest.Config , burstRestConfig * rest.Config ) {
343
- optr .enabledFeatureGates = cvoFlags
344
342
optr .release = update .Release
345
343
optr .releaseCreated = update .ImageRef .CreationTimestamp .Time
346
344
@@ -358,11 +356,13 @@ func (optr *Operator) InitializeFromPayload(update *payload.Update, requiredFeat
358
356
Cap : time .Second * 15 ,
359
357
},
360
358
optr .exclude ,
361
- requiredFeatureSet ,
359
+ optr . requiredFeatureSet ,
362
360
optr .eventRecorder ,
363
361
optr .clusterProfile ,
364
362
optr .alwaysEnableCapabilities ,
365
363
)
364
+
365
+ return nil
366
366
}
367
367
368
368
// ownerReferenceModifier sets the owner reference to the current CV resource if no other reference exists. It also resets
0 commit comments