kube-controller-manager: enable WatchListClient

This commit is contained in:
Lukasz Szaszkiewicz
2025-07-03 15:37:22 +02:00
parent 9cf00ec6d1
commit db342010f4
2 changed files with 10 additions and 4 deletions

View File

@@ -25,9 +25,11 @@ import (
v1 "k8s.io/api/core/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/version"
apiserveroptions "k8s.io/apiserver/pkg/server/options"
"k8s.io/apiserver/pkg/util/compatibility"
utilfeature "k8s.io/apiserver/pkg/util/feature"
clientgofeaturegate "k8s.io/client-go/features"
clientset "k8s.io/client-go/kubernetes"
clientgokubescheme "k8s.io/client-go/kubernetes/scheme"
restclient "k8s.io/client-go/rest"
@@ -38,6 +40,7 @@ import (
cpoptions "k8s.io/cloud-provider/options"
cliflag "k8s.io/component-base/cli/flag"
basecompatibility "k8s.io/component-base/compatibility"
"k8s.io/component-base/featuregate"
"k8s.io/component-base/logs"
logsapi "k8s.io/component-base/logs/api/v1"
"k8s.io/component-base/metrics"
@@ -295,6 +298,13 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).")
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).")
if !utilfeature.DefaultFeatureGate.Enabled(featuregate.Feature(clientgofeaturegate.WatchListClient)) {
ver := version.MustParse("1.34")
if err := utilfeature.DefaultMutableFeatureGate.OverrideDefaultAtVersion(featuregate.Feature(clientgofeaturegate.WatchListClient), true, ver); err != nil {
panic(fmt.Sprintf("unable to set %s feature gate, err: %v", clientgofeaturegate.WatchListClient, err))
}
}
s.ComponentGlobalsRegistry.AddFlags(fss.FlagSet("generic"))
return fss

View File

@@ -1469,8 +1469,6 @@ func TestControllerManagerAliases(t *testing.T) {
}
func TestWatchListClientFlagUsage(t *testing.T) {
t.Skip("skip this test until we either bring back WatchListClient or remove it")
fs := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
s, _ := NewKubeControllerManagerOptions()
for _, f := range s.Flags([]string{""}, []string{""}, nil).FlagSets {
@@ -1482,8 +1480,6 @@ func TestWatchListClientFlagUsage(t *testing.T) {
}
func TestWatchListClientFlagChange(t *testing.T) {
t.Skip("skip this test until we either bring back WatchListClient or remove it")
fs := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
s, err := NewKubeControllerManagerOptions()
if err != nil {