Skip to content

Commit fecf267

Browse files
committed
Do not execute CVOConfiguration logic in HyperShift
HyperShift will not create the ClusterVersionOperator CRD and CR. Thus, the relevant logic does not have to be running. Later, in HyperShift, we will configure the CVO to be configured via a configuration file instead.
1 parent 9ce6a03 commit fecf267

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

cmd/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func init() {
3939
cmd.PersistentFlags().StringVar(&opts.PromQLTarget.KubeSvc.Name, "metrics-service", opts.PromQLTarget.KubeSvc.Name, "The name of the remote PromQL query service. Must be specified when --use-dns-for-services is disabled.")
4040
cmd.PersistentFlags().BoolVar(&opts.PromQLTarget.UseDNS, "use-dns-for-services", opts.PromQLTarget.UseDNS, "Configures the CVO to use DNS for resolution of services in the cluster.")
4141
cmd.PersistentFlags().StringVar(&opts.PrometheusURLString, "metrics-url", opts.PrometheusURLString, "The URL used to access the remote PromQL query service.")
42-
cmd.PersistentFlags().BoolVar(&opts.InjectClusterIdIntoPromQL, "hypershift", opts.InjectClusterIdIntoPromQL, "This options indicates whether the CVO is running inside a hosted control plane.")
42+
cmd.PersistentFlags().BoolVar(&opts.HyperShift, "hypershift", opts.HyperShift, "This options indicates whether the CVO is running inside a hosted control plane.")
4343
cmd.PersistentFlags().StringVar(&opts.UpdateService, "update-service", opts.UpdateService, "The preferred update service. If set, this option overrides any upstream value configured in ClusterVersion spec.")
4444
cmd.PersistentFlags().StringSliceVar(&opts.AlwaysEnableCapabilities, "always-enable-capabilities", opts.AlwaysEnableCapabilities, "List of the cluster capabilities which will always be implicitly enabled.")
4545
rootCmd.AddCommand(cmd)

pkg/cvo/cvo.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ type Operator struct {
146146
// conditionRegistry is used to evaluate whether a particular condition is risky or not.
147147
conditionRegistry clusterconditions.ConditionRegistry
148148

149+
// hypershift signals whether the CVO is running inside a hosted control plane.
150+
hypershift bool
151+
149152
// injectClusterIdIntoPromQL indicates whether the CVO should inject the cluster id
150153
// into PromQL queries while evaluating risks from conditional updates. This is needed
151154
// in HyperShift to differentiate between metrics from multiple hosted clusters in
@@ -203,6 +206,7 @@ func New(
203206
operatorClient operatorclientset.Interface,
204207
exclude string,
205208
clusterProfile string,
209+
hypershift bool,
206210
promqlTarget clusterconditions.PromQLTarget,
207211
injectClusterIdIntoPromQL bool,
208212
updateService string,
@@ -234,6 +238,7 @@ func New(
234238
availableUpdatesQueue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "availableupdates"}),
235239
upgradeableQueue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "upgradeable"}),
236240

241+
hypershift: hypershift,
237242
exclude: exclude,
238243
clusterProfile: clusterProfile,
239244
conditionRegistry: standard.NewConditionRegistry(promqlTarget),
@@ -459,7 +464,7 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
459464
resultChannel <- asyncResult{name: "available updates"}
460465
}()
461466

462-
if optr.enabledFeatureGates.CVOConfiguration() {
467+
if optr.shouldReconcileCVOConfiguration() {
463468
resultChannelCount++
464469
go func() {
465470
defer utilruntime.HandleCrash()
@@ -473,7 +478,7 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
473478
resultChannel <- asyncResult{name: "cvo configuration"}
474479
}()
475480
} else {
476-
klog.Infof("The ClusterVersionOperatorConfiguration feature gate is disabled; skipping initialization of configuration sync routine")
481+
klog.Infof("The ClusterVersionOperatorConfiguration feature gate is disabled or HyperShift is detected; the configuration sync routine will not run.")
477482
}
478483

479484
resultChannelCount++
@@ -1042,3 +1047,11 @@ func (optr *Operator) HTTPClient() (*http.Client, error) {
10421047
Transport: transport,
10431048
}, nil
10441049
}
1050+
1051+
// shouldReconcileCVOConfiguration returns whether the CVO should reconcile its configuration using the API server.
1052+
//
1053+
// enabledFeatureGates must be initialized before the function is called.
1054+
func (optr *Operator) shouldReconcileCVOConfiguration() bool {
1055+
// The relevant CRD and CR are not applied in HyperShift, which configures the CVO via a configuration file
1056+
return optr.enabledFeatureGates.CVOConfiguration() && !optr.hypershift
1057+
}

pkg/start/start.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ type Options struct {
8484

8585
ClusterProfile string
8686

87+
HyperShift bool
88+
8789
// AlwaysEnableCapabilities is a list of cluster version capabilities
8890
// which will always be implicitly enabled.
8991
AlwaysEnableCapabilities []string
@@ -161,6 +163,9 @@ func (o *Options) Run(ctx context.Context) error {
161163
return fmt.Errorf("--always-enable-capabilities was set with unknown capabilities: %v", unknownCaps)
162164
}
163165

166+
// Inject the cluster ID into PromQL queries in HyperShift
167+
o.InjectClusterIdIntoPromQL = o.HyperShift
168+
164169
// parse the prometheus url
165170
var err error
166171
o.PromQLTarget.URL, err = url.Parse(o.PrometheusURLString)
@@ -502,6 +507,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder, alwaysEnableCapabiliti
502507
operatorClient,
503508
o.Exclude,
504509
o.ClusterProfile,
510+
o.HyperShift,
505511
o.PromQLTarget,
506512
o.InjectClusterIdIntoPromQL,
507513
o.UpdateService,

0 commit comments

Comments
 (0)