Skip to content

Commit

Permalink
Remove deprecated scheduler CLI flags
Browse files Browse the repository at this point in the history
  • Loading branch information
SataQiu committed Jul 7, 2023
1 parent d48fc2a commit 3a52685
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
4 changes: 0 additions & 4 deletions cmd/kube-scheduler/app/options/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")
}
6 changes: 0 additions & 6 deletions cmd/kube-scheduler/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
40 changes: 30 additions & 10 deletions cmd/kube-scheduler/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand All @@ -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
Expand All @@ -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,
},
},
{
Expand Down Expand Up @@ -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)
}
}
})
}
}
Expand Down

0 comments on commit 3a52685

Please sign in to comment.