Skip to content

Commit d2114e9

Browse files
committed
start using the new featuregateaccessor via the API
1 parent f3614d3 commit d2114e9

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

pkg/cmd/render/render_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,8 @@ func TestRenderCommand(t *testing.T) {
177177
"--controllers=-tokencleaner",
178178
"--controllers=-ttl",
179179
"--enable-dynamic-provisioning=true",
180-
"--feature-gates=APIPriorityAndFairness=true",
181-
"--feature-gates=DownwardAPIHugePages=true",
182180
"--feature-gates=OpenShiftPodSecurityAdmission=true",
183181
"--feature-gates=RetroactiveDefaultStorageClass=false",
184-
"--feature-gates=RotateKubeletServerCertificate=true",
185182
"--flex-volume-plugin-dir=/etc/kubernetes/kubelet-plugins/volume/exec",
186183
"--kube-api-burst=300",
187184
"--kube-api-qps=150",

pkg/operator/configobservation/cloud/observe_cloud_volume_plugin_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestObserveCloudVolumePlugin(t *testing.T) {
4444
FeatureGateSelection: configv1.FeatureGateSelection{
4545
FeatureSet: configv1.CustomNoUpgrade,
4646
CustomNoUpgrade: &configv1.CustomFeatureGates{
47-
Enabled: []string{cloudprovider.ExternalCloudProviderFeature},
47+
Enabled: []configv1.FeatureGateName{cloudprovider.ExternalCloudProviderFeature},
4848
},
4949
},
5050
},
@@ -78,7 +78,7 @@ func TestObserveCloudVolumePlugin(t *testing.T) {
7878
FeatureGateSelection: configv1.FeatureGateSelection{
7979
FeatureSet: configv1.CustomNoUpgrade,
8080
CustomNoUpgrade: &configv1.CustomFeatureGates{
81-
Enabled: []string{cloudprovider.ExternalCloudProviderFeature},
81+
Enabled: []configv1.FeatureGateName{cloudprovider.ExternalCloudProviderFeature},
8282
},
8383
},
8484
},

pkg/operator/configobservation/configobservercontroller/observe_config_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package configobservercontroller
22

33
import (
4+
configv1 "github.com/openshift/api/config/v1"
45
"k8s.io/apimachinery/pkg/util/sets"
56
"k8s.io/client-go/tools/cache"
67

@@ -30,7 +31,7 @@ import (
3031
// OpenShift. Passing these to KCM causes it to log an error on startup.
3132
// This list is passed to the feature gate config observer as a blacklist,
3233
// excluding them from the feature gate output passed to KCM.
33-
var openShiftOnlyFeatureGates = sets.NewString(
34+
var openShiftOnlyFeatureGates = sets.New[configv1.FeatureGateName](
3435
libgocloudprovider.ExternalCloudProviderFeature,
3536
)
3637

@@ -43,6 +44,7 @@ func NewConfigObserver(
4344
configinformers configinformers.SharedInformerFactory,
4445
kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces,
4546
resourceSyncer resourcesynccontroller.ResourceSyncer,
47+
featureGateAccessor featuregates.FeatureGateAccess,
4648
eventRecorder events.Recorder,
4749
) (*ConfigObserver, error) {
4850

@@ -124,13 +126,15 @@ func NewConfigObserver(
124126
nil,
125127
openShiftOnlyFeatureGates,
126128
[]string{"extendedArguments", "feature-gates"},
129+
featureGateAccessor,
127130
),
128131

129132
// this is picked up by the cluster-policy-controller container
130133
featuregates.NewObserveFeatureFlagsFunc(
131134
nil,
132135
nil,
133136
[]string{"featureGates"},
137+
featureGateAccessor,
134138
),
135139
network.ObserveClusterCIDRs,
136140
network.ObserveServiceClusterIPRanges,

pkg/operator/starter.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package operator
33
import (
44
"context"
55
"fmt"
6+
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
67
"os"
78
"time"
89

@@ -65,6 +66,27 @@ func RunOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
6566
}
6667
operatorLister := dynamicInformers.ForResource(operatorv1.GroupVersion.WithResource("kubecontrollermanagers")).Lister()
6768

69+
desiredVersion := status.VersionForOperatorFromEnv()
70+
missingVersion := "0.0.1-snapshot"
71+
72+
// By default, this will exit(0) the process if the featuregates ever change to a different set of values.
73+
featureGateAccessor := featuregates.NewFeatureGateAccess(
74+
desiredVersion, missingVersion,
75+
configInformers.Config().V1().ClusterVersions(), configInformers.Config().V1().FeatureGates(),
76+
cc.EventRecorder,
77+
)
78+
go featureGateAccessor.Run(ctx)
79+
go configInformers.Start(ctx.Done())
80+
81+
select {
82+
case <-featureGateAccessor.InitialFeatureGatesObserved():
83+
enabled, disabled, _ := featureGateAccessor.CurrentFeatureGates()
84+
klog.Infof("FeatureGates initialized: enabled=%v disabled=%v", enabled, disabled)
85+
case <-time.After(1 * time.Minute):
86+
klog.Errorf("timed out waiting for FeatureGate detection")
87+
return fmt.Errorf("timed out waiting for FeatureGate detection")
88+
}
89+
6890
resourceSyncController, err := resourcesynccontroller.NewResourceSyncController(
6991
operatorClient,
7092
kubeInformersForNamespaces,
@@ -81,6 +103,7 @@ func RunOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
81103
configInformers,
82104
kubeInformersForNamespaces,
83105
resourceSyncController,
106+
featureGateAccessor,
84107
cc.EventRecorder,
85108
)
86109
if err != nil {

0 commit comments

Comments
 (0)