Merge pull request #119130 from SataQiu/clean-sheduler-20230706
Remove deprecated scheduler CLI flags
This commit is contained in:
		@@ -28,8 +28,6 @@ import (
 | 
				
			|||||||
type DeprecatedOptions struct {
 | 
					type DeprecatedOptions struct {
 | 
				
			||||||
	componentbaseconfig.DebuggingConfiguration
 | 
						componentbaseconfig.DebuggingConfiguration
 | 
				
			||||||
	componentbaseconfig.ClientConnectionConfiguration
 | 
						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
 | 
						// PodMaxInUnschedulablePodsDuration is the maximum time a pod can stay in
 | 
				
			||||||
	// unschedulablePods. If a pod stays in unschedulablePods for longer than this
 | 
						// unschedulablePods. If a pod stays in unschedulablePods for longer than this
 | 
				
			||||||
	// value, the pod will be moved from unschedulablePods to backoffQ or activeQ.
 | 
						// 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.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.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.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")
 | 
						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")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -137,12 +137,6 @@ func (o *Options) ApplyDeprecated() {
 | 
				
			|||||||
	if deprecated.Changed("kube-api-burst") {
 | 
						if deprecated.Changed("kube-api-burst") {
 | 
				
			||||||
		o.ComponentConfig.ClientConnection.Burst = o.Deprecated.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`.
 | 
					// ApplyLeaderElectionTo obtains the CLI args related with leaderelection, and override the values in `cfg`.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -259,6 +259,7 @@ leaderElection:
 | 
				
			|||||||
		restoreFeatures      map[featuregate.Feature]bool
 | 
							restoreFeatures      map[featuregate.Feature]bool
 | 
				
			||||||
		wantPlugins          map[string]*config.Plugins
 | 
							wantPlugins          map[string]*config.Plugins
 | 
				
			||||||
		wantLeaderElection   *componentbaseconfig.LeaderElectionConfiguration
 | 
							wantLeaderElection   *componentbaseconfig.LeaderElectionConfiguration
 | 
				
			||||||
 | 
							wantClientConnection *componentbaseconfig.ClientConnectionConfiguration
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "default config with an alpha feature enabled",
 | 
								name: "default config with an alpha feature enabled",
 | 
				
			||||||
@@ -396,7 +397,7 @@ leaderElection:
 | 
				
			|||||||
			flags: []string{
 | 
								flags: []string{
 | 
				
			||||||
				"--leader-elect=false",
 | 
									"--leader-elect=false",
 | 
				
			||||||
				"--leader-elect-lease-duration=2h", // CLI args are favored over the fields in ComponentConfig
 | 
									"--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,
 | 
									"--config", emptyLeaderElectionConfig,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantLeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
 | 
								wantLeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
 | 
				
			||||||
@@ -408,14 +409,20 @@ leaderElection:
 | 
				
			|||||||
				ResourceName:      v1beta3.SchedulerDefaultLockObjectName,
 | 
									ResourceName:      v1beta3.SchedulerDefaultLockObjectName,
 | 
				
			||||||
				ResourceNamespace: v1beta3.SchedulerDefaultLockObjectNamespace,
 | 
									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",
 | 
								name: "leader election CLI args, without --config arg",
 | 
				
			||||||
			flags: []string{
 | 
								flags: []string{
 | 
				
			||||||
				"--leader-elect=false",
 | 
									"--leader-elect=false",
 | 
				
			||||||
				"--leader-elect-lease-duration=2h",
 | 
									"--leader-elect-lease-duration=2h",
 | 
				
			||||||
				"--lock-object-namespace=default", // deprecated CLI arg is honored if --config is not specified
 | 
									"--leader-elect-resource-namespace=default",
 | 
				
			||||||
				"--kubeconfig", configKubeconfig,
 | 
									"--kubeconfig", configKubeconfig, // deprecated CLI arg is honored if --config is not specified
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantLeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
 | 
								wantLeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
 | 
				
			||||||
				LeaderElect:       false,                                    // from CLI args
 | 
									LeaderElect:       false,                                    // from CLI args
 | 
				
			||||||
@@ -424,7 +431,13 @@ leaderElection:
 | 
				
			|||||||
				RetryPeriod:       metav1.Duration{Duration: 2 * time.Second},
 | 
									RetryPeriod:       metav1.Duration{Duration: 2 * time.Second},
 | 
				
			||||||
				ResourceLock:      "leases",
 | 
									ResourceLock:      "leases",
 | 
				
			||||||
				ResourceName:      v1beta3.SchedulerDefaultLockObjectName,
 | 
									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)
 | 
										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)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user