From 3a5268502f3e2df4acc5fdb439eee343941ff56d Mon Sep 17 00:00:00 2001 From: SataQiu Date: Fri, 7 Jul 2023 23:33:33 +0800 Subject: [PATCH] Remove deprecated scheduler CLI flags --- cmd/kube-scheduler/app/options/deprecated.go | 4 -- cmd/kube-scheduler/app/options/options.go | 6 --- cmd/kube-scheduler/app/server_test.go | 40 +++++++++++++++----- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/cmd/kube-scheduler/app/options/deprecated.go b/cmd/kube-scheduler/app/options/deprecated.go index d50fb1959a3..fe3bca1a40f 100644 --- a/cmd/kube-scheduler/app/options/deprecated.go +++ b/cmd/kube-scheduler/app/options/deprecated.go @@ -28,8 +28,6 @@ import ( type DeprecatedOptions struct { componentbaseconfig.DebuggingConfiguration componentbaseconfig.ClientConnectionConfiguration - // Note that only the deprecated options (lock-object-name and lock-object-namespace) are populated here. - componentbaseconfig.LeaderElectionConfiguration // PodMaxInUnschedulablePodsDuration is the maximum time a pod can stay in // unschedulablePods. If a pod stays in unschedulablePods for longer than this // value, the pod will be moved from unschedulablePods to backoffQ or activeQ. @@ -49,7 +47,5 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&o.ContentType, "kube-api-content-type", "application/vnd.kubernetes.protobuf", "DEPRECATED: content type of requests sent to apiserver. This parameter is ignored if a config file is specified in --config.") fs.Float32Var(&o.QPS, "kube-api-qps", 50.0, "DEPRECATED: QPS to use while talking with kubernetes apiserver. This parameter is ignored if a config file is specified in --config.") fs.Int32Var(&o.Burst, "kube-api-burst", 100, "DEPRECATED: burst to use while talking with kubernetes apiserver. This parameter is ignored if a config file is specified in --config.") - fs.StringVar(&o.ResourceNamespace, "lock-object-namespace", "kube-system", "DEPRECATED: define the namespace of the lock object. Will be removed in favor of leader-elect-resource-namespace. This parameter is ignored if a config file is specified in --config.") - fs.StringVar(&o.ResourceName, "lock-object-name", "kube-scheduler", "DEPRECATED: define the name of the lock object. Will be removed in favor of leader-elect-resource-name. This parameter is ignored if a config file is specified in --config.") fs.DurationVar(&o.PodMaxInUnschedulablePodsDuration, "pod-max-in-unschedulable-pods-duration", 5*time.Minute, "DEPRECATED: the maximum time a pod can stay in unschedulablePods. If a pod stays in unschedulablePods for longer than this value, the pod will be moved from unschedulablePods to backoffQ or activeQ. This flag is deprecated and will be removed in 1.26") } diff --git a/cmd/kube-scheduler/app/options/options.go b/cmd/kube-scheduler/app/options/options.go index 8e59234cac6..ac72f587c23 100644 --- a/cmd/kube-scheduler/app/options/options.go +++ b/cmd/kube-scheduler/app/options/options.go @@ -137,12 +137,6 @@ func (o *Options) ApplyDeprecated() { if deprecated.Changed("kube-api-burst") { o.ComponentConfig.ClientConnection.Burst = o.Deprecated.Burst } - if deprecated.Changed("lock-object-namespace") { - o.ComponentConfig.LeaderElection.ResourceNamespace = o.Deprecated.ResourceNamespace - } - if deprecated.Changed("lock-object-name") { - o.ComponentConfig.LeaderElection.ResourceName = o.Deprecated.ResourceName - } } // ApplyLeaderElectionTo obtains the CLI args related with leaderelection, and override the values in `cfg`. diff --git a/cmd/kube-scheduler/app/server_test.go b/cmd/kube-scheduler/app/server_test.go index 4df71babc99..04baa788e4a 100644 --- a/cmd/kube-scheduler/app/server_test.go +++ b/cmd/kube-scheduler/app/server_test.go @@ -253,12 +253,13 @@ leaderElection: } testcases := []struct { - name string - flags []string - registryOptions []Option - restoreFeatures map[featuregate.Feature]bool - wantPlugins map[string]*config.Plugins - wantLeaderElection *componentbaseconfig.LeaderElectionConfiguration + name string + flags []string + registryOptions []Option + restoreFeatures map[featuregate.Feature]bool + wantPlugins map[string]*config.Plugins + wantLeaderElection *componentbaseconfig.LeaderElectionConfiguration + wantClientConnection *componentbaseconfig.ClientConnectionConfiguration }{ { name: "default config with an alpha feature enabled", @@ -396,7 +397,7 @@ leaderElection: flags: []string{ "--leader-elect=false", "--leader-elect-lease-duration=2h", // CLI args are favored over the fields in ComponentConfig - "--lock-object-namespace=default", // deprecated CLI arg will be ignored if --config is specified + "--kubeconfig=foo", // deprecated CLI arg will be ignored if --config is specified "--config", emptyLeaderElectionConfig, }, wantLeaderElection: &componentbaseconfig.LeaderElectionConfiguration{ @@ -408,14 +409,20 @@ leaderElection: ResourceName: v1beta3.SchedulerDefaultLockObjectName, ResourceNamespace: v1beta3.SchedulerDefaultLockObjectNamespace, }, + wantClientConnection: &componentbaseconfig.ClientConnectionConfiguration{ + Kubeconfig: configKubeconfig, + ContentType: "application/vnd.kubernetes.protobuf", + QPS: 50, + Burst: 100, + }, }, { name: "leader election CLI args, without --config arg", flags: []string{ "--leader-elect=false", "--leader-elect-lease-duration=2h", - "--lock-object-namespace=default", // deprecated CLI arg is honored if --config is not specified - "--kubeconfig", configKubeconfig, + "--leader-elect-resource-namespace=default", + "--kubeconfig", configKubeconfig, // deprecated CLI arg is honored if --config is not specified }, wantLeaderElection: &componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: false, // from CLI args @@ -424,7 +431,13 @@ leaderElection: RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, ResourceLock: "leases", ResourceName: v1beta3.SchedulerDefaultLockObjectName, - ResourceNamespace: "default", // from deprecated CLI args + ResourceNamespace: "default", // from CLI args + }, + wantClientConnection: &componentbaseconfig.ClientConnectionConfiguration{ + Kubeconfig: configKubeconfig, // from deprecated CLI args + ContentType: "application/vnd.kubernetes.protobuf", + QPS: 50, + Burst: 100, }, }, { @@ -520,6 +533,13 @@ leaderElection: t.Errorf("Unexpected leaderElection diff (-want, +got): %s", diff) } } + + if tc.wantClientConnection != nil { + gotClientConnection := opts.ComponentConfig.ClientConnection + if diff := cmp.Diff(*tc.wantClientConnection, gotClientConnection); diff != "" { + t.Errorf("Unexpected clientConnection diff (-want, +got): %s", diff) + } + } }) } }