Skip to content

Commit 8250916

Browse files
committed
kube-controller-manager: enable WatchListClient
1 parent be00cde commit 8250916

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

cmd/kube-controller-manager/app/options/options.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
utilerrors "k8s.io/apimachinery/pkg/util/errors"
2626
apiserveroptions "k8s.io/apiserver/pkg/server/options"
2727
utilfeature "k8s.io/apiserver/pkg/util/feature"
28+
clientgofeaturegate "k8s.io/client-go/features"
2829
clientset "k8s.io/client-go/kubernetes"
2930
clientgokubescheme "k8s.io/client-go/kubernetes/scheme"
3031
restclient "k8s.io/client-go/rest"
@@ -33,10 +34,12 @@ import (
3334
cpnames "k8s.io/cloud-provider/names"
3435
cpoptions "k8s.io/cloud-provider/options"
3536
cliflag "k8s.io/component-base/cli/flag"
37+
"k8s.io/component-base/featuregate"
3638
"k8s.io/component-base/logs"
3739
logsapi "k8s.io/component-base/logs/api/v1"
3840
"k8s.io/component-base/metrics"
3941
cmoptions "k8s.io/controller-manager/options"
42+
"k8s.io/klog/v2"
4043
kubectrlmgrconfigv1alpha1 "k8s.io/kube-controller-manager/config/v1alpha1"
4144
kubecontrollerconfig "k8s.io/kubernetes/cmd/kube-controller-manager/app/config"
4245
"k8s.io/kubernetes/cmd/kube-controller-manager/names"
@@ -273,6 +276,16 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy
273276
fs := fss.FlagSet("misc")
274277
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).")
275278
fs.StringVar(&s.Generic.ClientConnection.Kubeconfig, "kubeconfig", s.Generic.ClientConnection.Kubeconfig, "Path to kubeconfig file with authorization and master location information (the master location can be overridden by the master flag).")
279+
280+
if !utilfeature.DefaultFeatureGate.Enabled(featuregate.Feature(clientgofeaturegate.WatchListClient)) {
281+
if err := utilfeature.DefaultMutableFeatureGate.OverrideDefault(featuregate.Feature(clientgofeaturegate.WatchListClient), true); err != nil {
282+
// it turns out that there are some integration tests that start multiple control plane components which
283+
// share global DefaultFeatureGate/DefaultMutableFeatureGate variables.
284+
// in those cases, the above call will fail (FG already registered and cannot be overridden), and the error will be logged.
285+
klog.Errorf("unable to set %s feature gate, err: %v", clientgofeaturegate.WatchListClient, err)
286+
}
287+
}
288+
276289
utilfeature.DefaultMutableFeatureGate.AddFlag(fss.FlagSet("generic"))
277290

278291
return fss

cmd/kube-controller-manager/app/options/options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,8 +1353,8 @@ func TestWatchListClientFlagChange(t *testing.T) {
13531353

13541354
func assertWatchListClientFeatureDefaultValue(t *testing.T) {
13551355
watchListClientDefaultValue := clientgofeaturegate.FeatureGates().Enabled(clientgofeaturegate.WatchListClient)
1356-
if watchListClientDefaultValue {
1357-
t.Fatalf("expected %q feature gate to be disabled for KCM", clientgofeaturegate.WatchListClient)
1356+
if !watchListClientDefaultValue {
1357+
t.Fatalf("expected %q feature gate to be enabled for KCM", clientgofeaturegate.WatchListClient)
13581358
}
13591359
}
13601360

@@ -1365,7 +1365,7 @@ func assertWatchListCommandLineDefaultValue(t *testing.T, fs *pflag.FlagSet) {
13651365
t.Fatalf("didn't find %q flag", fgFlagName)
13661366
}
13671367

1368-
expectedWatchListClientString := "WatchListClient=true|false (BETA - default=false)"
1368+
expectedWatchListClientString := "WatchListClient=true|false (BETA - default=true)"
13691369
if !strings.Contains(fg.Usage, expectedWatchListClientString) {
13701370
t.Fatalf("%q flag doesn't contain the expected usage for %v feature gate.\nExpected = %v\nUsage = %v", fgFlagName, clientgofeaturegate.WatchListClient, expectedWatchListClientString, fg.Usage)
13711371
}

0 commit comments

Comments
 (0)