diff --git a/cmd/kube-scheduler/app/options/options.go b/cmd/kube-scheduler/app/options/options.go index 540e2eb7356..cc3d0c30b3e 100644 --- a/cmd/kube-scheduler/app/options/options.go +++ b/cmd/kube-scheduler/app/options/options.go @@ -158,7 +158,7 @@ func (o *Options) Flags() (nfs cliflag.NamedFlagSets) { o.Authorization.AddFlags(nfs.FlagSet("authorization")) o.Deprecated.AddFlags(nfs.FlagSet("deprecated"), &o.ComponentConfig) - leaderelectionconfig.BindFlags(&o.ComponentConfig.LeaderElection.LeaderElectionConfiguration, nfs.FlagSet("leader election")) + leaderelectionconfig.BindFlags(&o.ComponentConfig.LeaderElection, nfs.FlagSet("leader election")) utilfeature.DefaultMutableFeatureGate.AddFlag(nfs.FlagSet("feature gate")) o.Metrics.AddFlags(nfs.FlagSet("metrics")) @@ -273,7 +273,7 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) { // makeLeaderElectionConfig builds a leader election configuration. It will // create a new resource lock associated with the configuration. -func makeLeaderElectionConfig(config kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration, client clientset.Interface, recorder record.EventRecorder) (*leaderelection.LeaderElectionConfig, error) { +func makeLeaderElectionConfig(config componentbaseconfig.LeaderElectionConfiguration, client clientset.Interface, recorder record.EventRecorder) (*leaderelection.LeaderElectionConfig, error) { hostname, err := os.Hostname() if err != nil { return nil, fmt.Errorf("unable to get hostname: %v", err) diff --git a/cmd/kube-scheduler/app/options/options_test.go b/cmd/kube-scheduler/app/options/options_test.go index e4b19627b0e..ad8c6cdad54 100644 --- a/cmd/kube-scheduler/app/options/options_test.go +++ b/cmd/kube-scheduler/app/options/options_test.go @@ -304,16 +304,14 @@ profiles: EnableProfiling: true, EnableContentionProfiling: true, }, - LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: configKubeconfig, @@ -396,16 +394,14 @@ profiles: EnableProfiling: true, EnableContentionProfiling: true, }, - LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: flagKubeconfig, @@ -462,16 +458,14 @@ profiles: EnableProfiling: true, EnableContentionProfiling: true, }, - LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: flagKubeconfig, @@ -503,16 +497,14 @@ profiles: EnableProfiling: true, EnableContentionProfiling: true, }, - LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: configKubeconfig, @@ -579,16 +571,14 @@ profiles: EnableProfiling: true, EnableContentionProfiling: true, }, - LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: configKubeconfig, @@ -653,16 +643,14 @@ profiles: EnableProfiling: true, EnableContentionProfiling: true, }, - LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: flagKubeconfig, @@ -707,16 +695,14 @@ profiles: EnableProfiling: true, EnableContentionProfiling: true, }, - LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: flagKubeconfig, diff --git a/pkg/scheduler/apis/config/types.go b/pkg/scheduler/apis/config/types.go index d9a1384b8a8..ea0161a015c 100644 --- a/pkg/scheduler/apis/config/types.go +++ b/pkg/scheduler/apis/config/types.go @@ -61,7 +61,7 @@ type KubeSchedulerConfiguration struct { AlgorithmSource SchedulerAlgorithmSource // LeaderElection defines the configuration of leader election client. - LeaderElection KubeSchedulerLeaderElectionConfiguration + LeaderElection componentbaseconfig.LeaderElectionConfiguration // ClientConnection specifies the kubeconfig file and client connection // settings for the proxy server to use when communicating with the apiserver. @@ -173,12 +173,6 @@ type SchedulerPolicyConfigMapSource struct { Name string } -// KubeSchedulerLeaderElectionConfiguration expands LeaderElectionConfiguration -// to include scheduler specific configuration. -type KubeSchedulerLeaderElectionConfiguration struct { - componentbaseconfig.LeaderElectionConfiguration -} - // Plugins include multiple extension points. When specified, the list of plugins for // a particular extension point are the only ones enabled. If an extension point is // omitted from the config, then the default set of plugins is used for that extension point. diff --git a/pkg/scheduler/apis/config/v1alpha2/defaults.go b/pkg/scheduler/apis/config/v1alpha2/defaults.go index 0e04f232203..42f061d1af7 100644 --- a/pkg/scheduler/apis/config/v1alpha2/defaults.go +++ b/pkg/scheduler/apis/config/v1alpha2/defaults.go @@ -127,7 +127,7 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1alpha2.KubeSchedulerConfigura } // Use the default LeaderElectionConfiguration options - componentbaseconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(&obj.LeaderElection.LeaderElectionConfiguration) + componentbaseconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(&obj.LeaderElection) if obj.BindTimeoutSeconds == nil { val := int64(600) diff --git a/pkg/scheduler/apis/config/v1alpha2/defaults_test.go b/pkg/scheduler/apis/config/v1alpha2/defaults_test.go index d7d5a4a6edb..b3da5dc34df 100644 --- a/pkg/scheduler/apis/config/v1alpha2/defaults_test.go +++ b/pkg/scheduler/apis/config/v1alpha2/defaults_test.go @@ -46,16 +46,14 @@ func TestSchedulerDefaults(t *testing.T) { EnableProfiling: &enable, EnableContentionProfiling: &enable, }, - LeaderElection: v1alpha2.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ QPS: 50, @@ -90,16 +88,14 @@ func TestSchedulerDefaults(t *testing.T) { EnableProfiling: &enable, EnableContentionProfiling: &enable, }, - LeaderElection: v1alpha2.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ QPS: 50, @@ -149,16 +145,14 @@ func TestSchedulerDefaults(t *testing.T) { EnableProfiling: &enable, EnableContentionProfiling: &enable, }, - LeaderElection: v1alpha2.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ QPS: 50, @@ -202,16 +196,14 @@ func TestSchedulerDefaults(t *testing.T) { EnableProfiling: &enable, EnableContentionProfiling: &enable, }, - LeaderElection: v1alpha2.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ QPS: 50, @@ -241,16 +233,14 @@ func TestSchedulerDefaults(t *testing.T) { EnableProfiling: &enable, EnableContentionProfiling: &enable, }, - LeaderElection: v1alpha2.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), - LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, - ResourceLock: "endpointsleases", - ResourceNamespace: "kube-system", - ResourceName: "kube-scheduler", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "endpointsleases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", }, ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ QPS: 50, diff --git a/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go b/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go index 533158fa282..ba1169f9044 100644 --- a/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go +++ b/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go @@ -50,16 +50,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1alpha2.KubeSchedulerLeaderElectionConfiguration)(nil), (*config.KubeSchedulerLeaderElectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(a.(*v1alpha2.KubeSchedulerLeaderElectionConfiguration), b.(*config.KubeSchedulerLeaderElectionConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*config.KubeSchedulerLeaderElectionConfiguration)(nil), (*v1alpha2.KubeSchedulerLeaderElectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_KubeSchedulerLeaderElectionConfiguration(a.(*config.KubeSchedulerLeaderElectionConfiguration), b.(*v1alpha2.KubeSchedulerLeaderElectionConfiguration), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*v1alpha2.KubeSchedulerProfile)(nil), (*config.KubeSchedulerProfile)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha2_KubeSchedulerProfile_To_config_KubeSchedulerProfile(a.(*v1alpha2.KubeSchedulerProfile), b.(*config.KubeSchedulerProfile), scope) }); err != nil { @@ -218,7 +208,7 @@ func Convert_config_InterPodAffinityArgs_To_v1alpha2_InterPodAffinityArgs(in *co } func autoConvert_v1alpha2_KubeSchedulerConfiguration_To_config_KubeSchedulerConfiguration(in *v1alpha2.KubeSchedulerConfiguration, out *config.KubeSchedulerConfiguration, s conversion.Scope) error { - if err := Convert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil { + if err := v1alpha1.Convert_v1alpha1_LeaderElectionConfiguration_To_config_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil { return err } if err := v1alpha1.Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(&in.ClientConnection, &out.ClientConnection, s); err != nil { @@ -265,7 +255,7 @@ func autoConvert_v1alpha2_KubeSchedulerConfiguration_To_config_KubeSchedulerConf func autoConvert_config_KubeSchedulerConfiguration_To_v1alpha2_KubeSchedulerConfiguration(in *config.KubeSchedulerConfiguration, out *v1alpha2.KubeSchedulerConfiguration, s conversion.Scope) error { // WARNING: in.AlgorithmSource requires manual conversion: does not exist in peer-type - if err := Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_KubeSchedulerLeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil { + if err := v1alpha1.Convert_config_LeaderElectionConfiguration_To_v1alpha1_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil { return err } if err := v1alpha1.Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(&in.ClientConnection, &out.ClientConnection, s); err != nil { @@ -310,30 +300,6 @@ func autoConvert_config_KubeSchedulerConfiguration_To_v1alpha2_KubeSchedulerConf return nil } -func autoConvert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in *v1alpha2.KubeSchedulerLeaderElectionConfiguration, out *config.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error { - if err := v1alpha1.Convert_v1alpha1_LeaderElectionConfiguration_To_config_LeaderElectionConfiguration(&in.LeaderElectionConfiguration, &out.LeaderElectionConfiguration, s); err != nil { - return err - } - return nil -} - -// Convert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function. -func Convert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in *v1alpha2.KubeSchedulerLeaderElectionConfiguration, out *config.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error { - return autoConvert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in, out, s) -} - -func autoConvert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_KubeSchedulerLeaderElectionConfiguration(in *config.KubeSchedulerLeaderElectionConfiguration, out *v1alpha2.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error { - if err := v1alpha1.Convert_config_LeaderElectionConfiguration_To_v1alpha1_LeaderElectionConfiguration(&in.LeaderElectionConfiguration, &out.LeaderElectionConfiguration, s); err != nil { - return err - } - return nil -} - -// Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function. -func Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_KubeSchedulerLeaderElectionConfiguration(in *config.KubeSchedulerLeaderElectionConfiguration, out *v1alpha2.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error { - return autoConvert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_KubeSchedulerLeaderElectionConfiguration(in, out, s) -} - func autoConvert_v1alpha2_KubeSchedulerProfile_To_config_KubeSchedulerProfile(in *v1alpha2.KubeSchedulerProfile, out *config.KubeSchedulerProfile, s conversion.Scope) error { if err := v1.Convert_Pointer_string_To_string(&in.SchedulerName, &out.SchedulerName, s); err != nil { return err diff --git a/pkg/scheduler/apis/config/validation/validation.go b/pkg/scheduler/apis/config/validation/validation.go index 35107339307..e48ae5dc6b7 100644 --- a/pkg/scheduler/apis/config/validation/validation.go +++ b/pkg/scheduler/apis/config/validation/validation.go @@ -35,7 +35,7 @@ import ( func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) field.ErrorList { allErrs := field.ErrorList{} allErrs = append(allErrs, componentbasevalidation.ValidateClientConnectionConfiguration(&cc.ClientConnection, field.NewPath("clientConnection"))...) - allErrs = append(allErrs, validateKubeSchedulerLeaderElectionConfiguration(field.NewPath("leaderElection"), &cc.LeaderElection)...) + allErrs = append(allErrs, componentbasevalidation.ValidateLeaderElectionConfiguration(&cc.LeaderElection, field.NewPath("leaderElection"))...) profilesPath := field.NewPath("profiles") if len(cc.Profiles) == 0 { @@ -103,15 +103,6 @@ func validateCommonQueueSort(path *field.Path, profiles []config.KubeSchedulerPr return allErrs } -func validateKubeSchedulerLeaderElectionConfiguration(fldPath *field.Path, cc *config.KubeSchedulerLeaderElectionConfiguration) field.ErrorList { - allErrs := field.ErrorList{} - if !cc.LeaderElectionConfiguration.LeaderElect { - return allErrs - } - allErrs = append(allErrs, componentbasevalidation.ValidateLeaderElectionConfiguration(&cc.LeaderElectionConfiguration, fldPath)...) - return allErrs -} - // ValidatePolicy checks for errors in the Config // It does not return early so that it can find as many errors as possible func ValidatePolicy(policy config.Policy) error { diff --git a/pkg/scheduler/apis/config/validation/validation_test.go b/pkg/scheduler/apis/config/validation/validation_test.go index afa496d831e..539e251121c 100644 --- a/pkg/scheduler/apis/config/validation/validation_test.go +++ b/pkg/scheduler/apis/config/validation/validation_test.go @@ -48,16 +48,14 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) { }, }, }, - LeaderElection: config.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ - ResourceLock: "configmap", - LeaderElect: true, - LeaseDuration: metav1.Duration{Duration: 30 * time.Second}, - RenewDeadline: metav1.Duration{Duration: 15 * time.Second}, - RetryPeriod: metav1.Duration{Duration: 5 * time.Second}, - ResourceNamespace: "name", - ResourceName: "name", - }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + ResourceLock: "configmap", + LeaderElect: true, + LeaseDuration: metav1.Duration{Duration: 30 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 15 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 5 * time.Second}, + ResourceNamespace: "name", + ResourceName: "name", }, PodInitialBackoffSeconds: podInitialBackoffSeconds, PodMaxBackoffSeconds: podMaxBackoffSeconds, diff --git a/pkg/scheduler/apis/config/zz_generated.deepcopy.go b/pkg/scheduler/apis/config/zz_generated.deepcopy.go index 8b3d0a3f873..cf261eefbb4 100644 --- a/pkg/scheduler/apis/config/zz_generated.deepcopy.go +++ b/pkg/scheduler/apis/config/zz_generated.deepcopy.go @@ -166,23 +166,6 @@ func (in *KubeSchedulerConfiguration) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubeSchedulerLeaderElectionConfiguration) DeepCopyInto(out *KubeSchedulerLeaderElectionConfiguration) { - *out = *in - out.LeaderElectionConfiguration = in.LeaderElectionConfiguration - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeSchedulerLeaderElectionConfiguration. -func (in *KubeSchedulerLeaderElectionConfiguration) DeepCopy() *KubeSchedulerLeaderElectionConfiguration { - if in == nil { - return nil - } - out := new(KubeSchedulerLeaderElectionConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeSchedulerProfile) DeepCopyInto(out *KubeSchedulerProfile) { *out = *in diff --git a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go index b82105939a0..155103531f9 100644 --- a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go +++ b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go @@ -45,7 +45,7 @@ type KubeSchedulerConfiguration struct { metav1.TypeMeta `json:",inline"` // LeaderElection defines the configuration of leader election client. - LeaderElection KubeSchedulerLeaderElectionConfiguration `json:"leaderElection"` + LeaderElection componentbaseconfigv1alpha1.LeaderElectionConfiguration `json:"leaderElection"` // ClientConnection specifies the kubeconfig file and client connection // settings for the proxy server to use when communicating with the apiserver. @@ -156,12 +156,6 @@ type KubeSchedulerProfile struct { PluginConfig []PluginConfig `json:"pluginConfig,omitempty"` } -// KubeSchedulerLeaderElectionConfiguration expands LeaderElectionConfiguration -// to include scheduler specific configuration. -type KubeSchedulerLeaderElectionConfiguration struct { - componentbaseconfigv1alpha1.LeaderElectionConfiguration `json:",inline"` -} - // Plugins include multiple extension points. When specified, the list of plugins for // a particular extension point are the only ones enabled. If an extension point is // omitted from the config, then the default set of plugins is used for that extension point. diff --git a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/zz_generated.deepcopy.go b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/zz_generated.deepcopy.go index 88bbaba8bd9..993b8c1ded6 100644 --- a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/zz_generated.deepcopy.go @@ -133,23 +133,6 @@ func (in *KubeSchedulerConfiguration) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubeSchedulerLeaderElectionConfiguration) DeepCopyInto(out *KubeSchedulerLeaderElectionConfiguration) { - *out = *in - in.LeaderElectionConfiguration.DeepCopyInto(&out.LeaderElectionConfiguration) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeSchedulerLeaderElectionConfiguration. -func (in *KubeSchedulerLeaderElectionConfiguration) DeepCopy() *KubeSchedulerLeaderElectionConfiguration { - if in == nil { - return nil - } - out := new(KubeSchedulerLeaderElectionConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeSchedulerProfile) DeepCopyInto(out *KubeSchedulerProfile) { *out = *in