@@ -53,6 +53,7 @@ import (
5353 "github.com/openshift/cluster-version-operator/pkg/payload"
5454 "github.com/openshift/cluster-version-operator/pkg/payload/precondition"
5555 preconditioncv "github.com/openshift/cluster-version-operator/pkg/payload/precondition/clusterversion"
56+ "github.com/openshift/cluster-version-operator/pkg/proposal"
5657 "github.com/openshift/cluster-version-operator/pkg/risk"
5758 "github.com/openshift/cluster-version-operator/pkg/risk/alert"
5859)
@@ -213,6 +214,9 @@ type Operator struct {
213214 // risks holds update-risk source (in-cluster alerts, etc.)
214215 // that will be aggregated into conditional update risks.
215216 risks risk.Source
217+
218+ // proposalController, if enabled, watch available updates and manage proposals
219+ proposalController * proposal.Controller
216220}
217221
218222// New returns a new cluster version operator.
@@ -317,6 +321,13 @@ func New(
317321
318322 optr .configuration = configuration .NewClusterVersionOperatorConfiguration (operatorClient , operatorInformerFactory )
319323
324+ optr .proposalController = proposal .NewController (func () ([]configv1.Release , error ) {
325+ if optr .availableUpdates == nil {
326+ return nil , nil
327+ }
328+ return optr .availableUpdates .Updates , nil
329+ })
330+
320331 return optr , nil
321332}
322333
@@ -470,6 +481,7 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
470481 defer optr .availableUpdatesQueue .ShutDown ()
471482 defer optr .upgradeableQueue .ShutDown ()
472483 defer optr .configuration .Queue ().ShutDown ()
484+ defer optr .proposalController .Queue ().ShutDown ()
473485 stopCh := runContext .Done ()
474486
475487 klog .Infof ("Starting ClusterVersionOperator with minimum reconcile period %s" , optr .minimumUpdateCheckInterval )
@@ -525,6 +537,19 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
525537 klog .Infof ("The ClusterVersionOperatorConfiguration feature gate is disabled or HyperShift is detected; the configuration sync routine will not run." )
526538 }
527539
540+ if optr .shouldEnableProposalController () {
541+ resultChannelCount ++
542+ go func () {
543+ defer utilruntime .HandleCrash ()
544+ wait .UntilWithContext (runContext , func (runContext context.Context ) {
545+ optr .worker (runContext , optr .proposalController .Queue (), optr .proposalController .Sync )
546+ }, time .Second )
547+ resultChannel <- asyncResult {name : "proposal controller" }
548+ }()
549+ } else {
550+ klog .Infof ("The proposal controller is disabled." )
551+ }
552+
528553 resultChannelCount ++
529554 go func () {
530555 defer utilruntime .HandleCrash ()
@@ -595,6 +620,7 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
595620 optr .availableUpdatesQueue .ShutDown ()
596621 optr .upgradeableQueue .ShutDown ()
597622 optr .configuration .Queue ().ShutDown ()
623+ optr .proposalController .Queue ().ShutDown ()
598624 }
599625 }
600626
@@ -1191,3 +1217,9 @@ func (optr *Operator) shouldReconcileAcceptRisks() bool {
11911217 // HyperShift will be supported later if needed
11921218 return optr .enabledCVOFeatureGates .AcceptRisks () && ! optr .hypershift
11931219}
1220+
1221+ // shouldEnableProposalController returns whether the CVO should enable the proposal controller
1222+ func (optr * Operator ) shouldEnableProposalController () bool {
1223+ // TODO: guarded by some feature gate?
1224+ return true
1225+ }
0 commit comments