Skip to content

Commit 903e16e

Browse files
committed
Rename enabledFeatureGates to enabledCVOFeatureGates
1 parent 10b7a6c commit 903e16e

6 files changed

Lines changed: 27 additions & 24 deletions

File tree

pkg/cvo/cvo.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,22 @@ type Operator struct {
180180
// to select the manifests that will be applied in the cluster. The starting value cannot be changed in the executing
181181
// CVO but the featurechangestopper controller will detect a feature set change in the cluster and shutdown the CVO.
182182
// Enforcing featuresets is a standard GA CVO behavior that supports the feature gating functionality across the whole
183-
// cluster, as opposed to the enabledFeatureGates which controls what gated behaviors of CVO itself are enabled by
183+
// cluster, as opposed to the enabledCVOFeatureGates which controls what gated behaviors of CVO itself are enabled by
184184
// the cluster feature gates.
185185
// See: https://github.com/openshift/enhancements/blob/master/enhancements/update/cvo-techpreview-manifests.md
186186
requiredFeatureSet configv1.FeatureSet
187187

188-
// enabledFeatureGates is the checker for what gated CVO behaviors are enabled or disabled by specific cluster-level
188+
// enabledCVOFeatureGates is the checker for what gated CVO behaviors are enabled or disabled by specific cluster-level
189189
// feature gates. It allows multiplexing the cluster-level feature gates to more granular CVO-level gates. Similarly
190-
// to the requiredFeatureSet, the enabledFeatureGates cannot be changed in the executing CVO but the
190+
// to the requiredFeatureSet, the enabledCVOFeatureGates cannot be changed in the executing CVO but the
191191
// featurechangestopper controller will detect when cluster feature gate config changes and shutdown the CVO.
192-
enabledFeatureGates featuregates.CvoGateChecker
192+
enabledCVOFeatureGates featuregates.CvoGateChecker
193193

194194
// featureGatesMutex protects access to enabledManifestFeatureGates
195-
featureGatesMutex sync.RWMutex
195+
featureGatesMutex sync.RWMutex
196+
// enabledManifestFeatureGates is the set of feature gates that are currently enabled for the manifests that are applied to the cluster.
197+
// This is the full set of enabled feature gates extracted from the FeatureGate object.
198+
// We use this set as a filter to determine which of the manifests from the payload should or should not be applied to the cluster.
196199
enabledManifestFeatureGates sets.Set[string]
197200

198201
clusterProfile string
@@ -267,7 +270,7 @@ func New(
267270
injectClusterIdIntoPromQL: injectClusterIdIntoPromQL,
268271

269272
requiredFeatureSet: featureSet,
270-
enabledFeatureGates: cvoGates,
273+
enabledCVOFeatureGates: cvoGates,
271274
enabledManifestFeatureGates: startingEnabledManifestFeatureGates,
272275

273276
alwaysEnableCapabilities: alwaysEnableCapabilities,
@@ -1159,18 +1162,18 @@ func (optr *Operator) extractEnabledGates(featureGate *configv1.FeatureGate) set
11591162
currentVersion := optr.currentVersion().Version
11601163
if currentVersion == "" {
11611164
klog.Warningf("Payload has not been initialized yet, using the operator version %s", optr.enabledCVOFeatureGates.DesiredVersion())
1162-
currentVersion = optr.enabledFeatureGates.DesiredVersion()
1165+
currentVersion = optr.enabledCVOFeatureGates.DesiredVersion()
11631166
}
11641167

11651168
return featuregates.ExtractEnabledGates(featureGate, currentVersion)
11661169
}
11671170

11681171
// shouldReconcileCVOConfiguration returns whether the CVO should reconcile its configuration using the API server.
11691172
//
1170-
// enabledFeatureGates must be initialized before the function is called.
1173+
// enabledCVOFeatureGates must be initialized before the function is called.
11711174
func (optr *Operator) shouldReconcileCVOConfiguration() bool {
11721175
// The relevant CRD and CR are not applied in HyperShift, which configures the CVO via a configuration file
1173-
return optr.enabledFeatureGates.CVOConfiguration() && !optr.hypershift
1176+
return optr.enabledCVOFeatureGates.CVOConfiguration() && !optr.hypershift
11741177
}
11751178

11761179
// shouldReconcileAcceptRisks returns whether the CVO should reconcile spec.desiredUpdate.acceptRisks and populate the

pkg/cvo/cvo_featuregates_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestOperator_extractEnabledGates(t *testing.T) {
7676
t.Run(tt.name, func(t *testing.T) {
7777
optr := &Operator{
7878
release: tt.release,
79-
enabledFeatureGates: fakeRiFlags{
79+
enabledCVOFeatureGates: fakeRiFlags{
8080
desiredVersion: tt.release.Version,
8181
},
8282
}
@@ -150,7 +150,7 @@ func TestOperator_updateEnabledFeatureGates(t *testing.T) {
150150
optr := &Operator{
151151
enabledManifestFeatureGates: sets.New[string]("oldgate"),
152152
release: configv1.Release{Version: "4.14.0"},
153-
enabledFeatureGates: fakeRiFlags{
153+
enabledCVOFeatureGates: fakeRiFlags{
154154
desiredVersion: "4.14.0",
155155
},
156156
}

pkg/cvo/cvo_scenarios_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ func setupCVOTest(payloadDir string) (*Operator, map[string]apiruntime.Object, *
115115
}
116116

117117
o := &Operator{
118-
namespace: "test",
119-
name: "version",
120-
queue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "cvo-loop-test"}),
121-
client: client,
122-
enabledFeatureGates: featuregates.DefaultCvoGates("version"),
123-
cvLister: &clientCVLister{client: client},
124-
exclude: "exclude-test",
125-
eventRecorder: record.NewFakeRecorder(100),
126-
clusterProfile: payload.DefaultClusterProfile,
118+
namespace: "test",
119+
name: "version",
120+
queue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "cvo-loop-test"}),
121+
client: client,
122+
enabledCVOFeatureGates: featuregates.DefaultCvoGates("version"),
123+
cvLister: &clientCVLister{client: client},
124+
exclude: "exclude-test",
125+
eventRecorder: record.NewFakeRecorder(100),
126+
clusterProfile: payload.DefaultClusterProfile,
127127
}
128128

129129
dynamicScheme := apiruntime.NewScheme()

pkg/cvo/cvo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ func TestOperator_sync(t *testing.T) {
22752275
optr.configSync = &fakeSyncRecorder{Returns: expectStatus}
22762276
}
22772277
optr.eventRecorder = record.NewFakeRecorder(100)
2278-
optr.enabledFeatureGates = featuregates.DefaultCvoGates("version")
2278+
optr.enabledCVOFeatureGates = featuregates.DefaultCvoGates("version")
22792279

22802280
ctx := context.Background()
22812281
err := optr.sync(ctx, optr.queueKey())

pkg/cvo/featuregate_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func TestFeatureGateEventHandling(t *testing.T) {
164164
// Create a simple operator with feature gate management capabilities
165165
optr := &Operator{
166166
release: configv1.Release{Version: "4.14.0"},
167-
enabledFeatureGates: fakeRiFlags{
167+
enabledCVOFeatureGates: fakeRiFlags{
168168
desiredVersion: "4.14.0",
169169
},
170170
}

pkg/cvo/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (optr *Operator) syncStatus(ctx context.Context, original, config *configv1
164164

165165
cvUpdated := false
166166
// update the config with the latest available updates
167-
if updated := optr.getAvailableUpdates().NeedsUpdate(config, optr.enabledFeatureGates.StatusReleaseArchitecture()); updated != nil {
167+
if updated := optr.getAvailableUpdates().NeedsUpdate(config, optr.enabledCVOFeatureGates.StatusReleaseArchitecture()); updated != nil {
168168
cvUpdated = true
169169
config = updated
170170
}
@@ -177,7 +177,7 @@ func (optr *Operator) syncStatus(ctx context.Context, original, config *configv1
177177
original = config.DeepCopy()
178178
}
179179

180-
updateClusterVersionStatus(&config.Status, status, optr.release, optr.getAvailableUpdates, optr.enabledFeatureGates, validationErrs, optr.shouldReconcileAcceptRisks)
180+
updateClusterVersionStatus(&config.Status, status, optr.release, optr.getAvailableUpdates, optr.enabledCVOFeatureGates, validationErrs, optr.shouldReconcileAcceptRisks)
181181

182182
if klog.V(6).Enabled() {
183183
klog.Infof("Apply config: %s", cmp.Diff(original, config))

0 commit comments

Comments
 (0)