Skip to content

Commit 12099d8

Browse files
committed
config: Conditionally initialize configuration controller
The information regarding enabled feature gates is now available sooner in the code. Utilize this information to conditionally initialize the configuration controller. The subsequent code can then easily check for existence of the configuration using a nil.
1 parent 539bd46 commit 12099d8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/cvo/cvo.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ func New(
290290
// make sure this is initialized after all the listers are initialized
291291
optr.upgradeableChecks = optr.defaultUpgradeableChecks()
292292

293-
optr.configuration = configuration.NewClusterVersionOperatorConfiguration(operatorClient, operatorInformerFactory)
293+
if shouldReconcileCVOConfiguration(cvoGates, optr.hypershift) {
294+
optr.configuration = configuration.NewClusterVersionOperatorConfiguration(operatorClient, operatorInformerFactory)
295+
}
294296

295297
return optr, nil
296298
}
@@ -483,7 +485,7 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
483485
resultChannel <- asyncResult{name: "available updates"}
484486
}()
485487

486-
if optr.shouldReconcileCVOConfiguration() {
488+
if optr.configuration != nil {
487489
resultChannelCount++
488490
go func() {
489491
defer utilruntime.HandleCrash()
@@ -1070,7 +1072,7 @@ func (optr *Operator) HTTPClient() (*http.Client, error) {
10701072
// shouldReconcileCVOConfiguration returns whether the CVO should reconcile its configuration using the API server.
10711073
//
10721074
// enabledFeatureGates must be initialized before the function is called.
1073-
func (optr *Operator) shouldReconcileCVOConfiguration() bool {
1075+
func shouldReconcileCVOConfiguration(enabledFeatureGates featuregates.CvoGateChecker, isHypershift bool) bool {
10741076
// The relevant CRD and CR are not applied in HyperShift, which configures the CVO via a configuration file
1075-
return optr.enabledFeatureGates.CVOConfiguration() && !optr.hypershift
1077+
return enabledFeatureGates.CVOConfiguration() && !isHypershift
10761078
}

0 commit comments

Comments
 (0)