diff --git a/pkg/scheduler/apis/config/scheme/scheme_test.go b/pkg/scheduler/apis/config/scheme/scheme_test.go index 4bccb67db8b..2a0133f2873 100644 --- a/pkg/scheduler/apis/config/scheme/scheme_test.go +++ b/pkg/scheduler/apis/config/scheme/scheme_test.go @@ -78,6 +78,9 @@ profiles: resources: - name: memory weight: 1 + - name: VolumeBinding + args: + bindTimeoutSeconds: 300 `), wantProfiles: []config.KubeSchedulerProfile{ { @@ -128,6 +131,12 @@ profiles: Resources: []config.ResourceSpec{{Name: "memory", Weight: 1}}, }, }, + { + Name: "VolumeBinding", + Args: &config.VolumeBindingArgs{ + BindTimeoutSeconds: 300, + }, + }, }, }, }, @@ -255,6 +264,8 @@ profiles: args: - name: NodeResourcesMostAllocated args: + - name: VolumeBinding + args: `), wantProfiles: []config.KubeSchedulerProfile{ { @@ -283,6 +294,12 @@ profiles: Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}}, }, }, + { + Name: "VolumeBinding", + Args: &config.VolumeBindingArgs{ + BindTimeoutSeconds: 600, + }, + }, }, }, }, @@ -334,6 +351,14 @@ func TestCodecsEncodePluginConfig(t *testing.T) { }, }, }, + { + Name: "VolumeBinding", + Args: runtime.RawExtension{ + Object: &v1alpha2.VolumeBindingArgs{ + BindTimeoutSeconds: pointer.Int64Ptr(300), + }, + }, + }, { Name: "RequestedToCapacityRatio", Args: runtime.RawExtension{ @@ -390,6 +415,11 @@ profiles: hardPodAffinityWeight: 5 kind: InterPodAffinityArgs name: InterPodAffinity + - args: + apiVersion: kubescheduler.config.k8s.io/v1alpha2 + bindTimeoutSeconds: 300 + kind: VolumeBindingArgs + name: VolumeBinding - args: apiVersion: kubescheduler.config.k8s.io/v1alpha2 kind: RequestedToCapacityRatioArgs @@ -431,6 +461,12 @@ profiles: Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}}, }, }, + { + Name: "VolumeBinding", + Args: &config.VolumeBindingArgs{ + BindTimeoutSeconds: 300, + }, + }, { Name: "OutOfTreePlugin", Args: &runtime.Unknown{ @@ -480,6 +516,11 @@ profiles: - Name: cpu Weight: 1 name: NodeResourcesMostAllocated + - args: + apiVersion: kubescheduler.config.k8s.io/v1alpha2 + bindTimeoutSeconds: 300 + kind: VolumeBindingArgs + name: VolumeBinding - args: foo: bar name: OutOfTreePlugin diff --git a/pkg/scheduler/apis/config/types.go b/pkg/scheduler/apis/config/types.go index 0b5f57f4255..8207264d033 100644 --- a/pkg/scheduler/apis/config/types.go +++ b/pkg/scheduler/apis/config/types.go @@ -90,7 +90,7 @@ type KubeSchedulerConfiguration struct { // nodes will be scored. PercentageOfNodesToScore int32 - // Duration to wait for a binding operation to complete before timing out + // BindTimeoutSeconds is the timeout in seconds in volume binding operation. // Value must be non-negative integer. The value zero indicates no waiting. // If this value is nil, the default value will be used. // DEPRECATED: BindTimeoutSeconds in deprecated. diff --git a/pkg/scheduler/apis/config/types_pluginargs.go b/pkg/scheduler/apis/config/types_pluginargs.go index a62789e6c23..d8964a73ee4 100644 --- a/pkg/scheduler/apis/config/types_pluginargs.go +++ b/pkg/scheduler/apis/config/types_pluginargs.go @@ -148,6 +148,8 @@ type ServiceAffinityArgs struct { type VolumeBindingArgs struct { metav1.TypeMeta - // BindTimeoutSeconds is the timeout in seconds in volume binding. + // BindTimeoutSeconds is the timeout in seconds in volume binding operation. + // Value must be non-negative integer. The value zero indicates no waiting. + // If this value is nil, the default value will be used. BindTimeoutSeconds int64 } diff --git a/pkg/scheduler/apis/config/v1alpha2/defaults.go b/pkg/scheduler/apis/config/v1alpha2/defaults.go index 2f8113e7baa..7dd9751afc5 100644 --- a/pkg/scheduler/apis/config/v1alpha2/defaults.go +++ b/pkg/scheduler/apis/config/v1alpha2/defaults.go @@ -192,3 +192,9 @@ func SetDefaults_RequestedToCapacityRatioArgs(obj *v1alpha2.RequestedToCapacityR obj.Resources = append(obj.Resources, defaultResourceSpec...) } } + +func SetDefaults_VolumeBindingArgs(obj *v1alpha2.VolumeBindingArgs) { + if obj.BindTimeoutSeconds == nil { + obj.BindTimeoutSeconds = pointer.Int64Ptr(600) + } +} diff --git a/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go b/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go index f3ef14b0d51..09692d14c26 100644 --- a/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go +++ b/pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go @@ -190,6 +190,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*v1alpha2.VolumeBindingArgs)(nil), (*config.VolumeBindingArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha2_VolumeBindingArgs_To_config_VolumeBindingArgs(a.(*v1alpha2.VolumeBindingArgs), b.(*config.VolumeBindingArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.VolumeBindingArgs)(nil), (*v1alpha2.VolumeBindingArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_VolumeBindingArgs_To_v1alpha2_VolumeBindingArgs(a.(*config.VolumeBindingArgs), b.(*v1alpha2.VolumeBindingArgs), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*config.KubeSchedulerConfiguration)(nil), (*v1alpha2.KubeSchedulerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_config_KubeSchedulerConfiguration_To_v1alpha2_KubeSchedulerConfiguration(a.(*config.KubeSchedulerConfiguration), b.(*v1alpha2.KubeSchedulerConfiguration), scope) }); err != nil { @@ -907,3 +917,27 @@ func autoConvert_config_UtilizationShapePoint_To_v1alpha2_UtilizationShapePoint( func Convert_config_UtilizationShapePoint_To_v1alpha2_UtilizationShapePoint(in *config.UtilizationShapePoint, out *v1alpha2.UtilizationShapePoint, s conversion.Scope) error { return autoConvert_config_UtilizationShapePoint_To_v1alpha2_UtilizationShapePoint(in, out, s) } + +func autoConvert_v1alpha2_VolumeBindingArgs_To_config_VolumeBindingArgs(in *v1alpha2.VolumeBindingArgs, out *config.VolumeBindingArgs, s conversion.Scope) error { + if err := v1.Convert_Pointer_int64_To_int64(&in.BindTimeoutSeconds, &out.BindTimeoutSeconds, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha2_VolumeBindingArgs_To_config_VolumeBindingArgs is an autogenerated conversion function. +func Convert_v1alpha2_VolumeBindingArgs_To_config_VolumeBindingArgs(in *v1alpha2.VolumeBindingArgs, out *config.VolumeBindingArgs, s conversion.Scope) error { + return autoConvert_v1alpha2_VolumeBindingArgs_To_config_VolumeBindingArgs(in, out, s) +} + +func autoConvert_config_VolumeBindingArgs_To_v1alpha2_VolumeBindingArgs(in *config.VolumeBindingArgs, out *v1alpha2.VolumeBindingArgs, s conversion.Scope) error { + if err := v1.Convert_int64_To_Pointer_int64(&in.BindTimeoutSeconds, &out.BindTimeoutSeconds, s); err != nil { + return err + } + return nil +} + +// Convert_config_VolumeBindingArgs_To_v1alpha2_VolumeBindingArgs is an autogenerated conversion function. +func Convert_config_VolumeBindingArgs_To_v1alpha2_VolumeBindingArgs(in *config.VolumeBindingArgs, out *v1alpha2.VolumeBindingArgs, s conversion.Scope) error { + return autoConvert_config_VolumeBindingArgs_To_v1alpha2_VolumeBindingArgs(in, out, s) +} diff --git a/pkg/scheduler/apis/config/v1alpha2/zz_generated.defaults.go b/pkg/scheduler/apis/config/v1alpha2/zz_generated.defaults.go index 35fae195953..065942682d0 100644 --- a/pkg/scheduler/apis/config/v1alpha2/zz_generated.defaults.go +++ b/pkg/scheduler/apis/config/v1alpha2/zz_generated.defaults.go @@ -42,6 +42,7 @@ func RegisterDefaults(scheme *runtime.Scheme) error { scheme.AddTypeDefaultingFunc(&v1alpha2.RequestedToCapacityRatioArgs{}, func(obj interface{}) { SetObjectDefaults_RequestedToCapacityRatioArgs(obj.(*v1alpha2.RequestedToCapacityRatioArgs)) }) + scheme.AddTypeDefaultingFunc(&v1alpha2.VolumeBindingArgs{}, func(obj interface{}) { SetObjectDefaults_VolumeBindingArgs(obj.(*v1alpha2.VolumeBindingArgs)) }) return nil } @@ -64,3 +65,7 @@ func SetObjectDefaults_NodeResourcesMostAllocatedArgs(in *v1alpha2.NodeResources func SetObjectDefaults_RequestedToCapacityRatioArgs(in *v1alpha2.RequestedToCapacityRatioArgs) { SetDefaults_RequestedToCapacityRatioArgs(in) } + +func SetObjectDefaults_VolumeBindingArgs(in *v1alpha2.VolumeBindingArgs) { + SetDefaults_VolumeBindingArgs(in) +} diff --git a/pkg/scheduler/framework/v1alpha1/framework_test.go b/pkg/scheduler/framework/v1alpha1/framework_test.go index 40aa696ca0f..b7045a8e3bb 100644 --- a/pkg/scheduler/framework/v1alpha1/framework_test.go +++ b/pkg/scheduler/framework/v1alpha1/framework_test.go @@ -470,7 +470,16 @@ func recordingPluginFactory(name string, result map[string]runtime.Object) Plugi func TestNewFrameworkPluginDefaults(t *testing.T) { // In-tree plugins that use args. - pluginsWithArgs := []string{"InterPodAffinity", "NodeLabel", "NodeResourcesFit", "NodeResourcesLeastAllocated", "NodeResourcesMostAllocated", "PodTopologySpread", "RequestedToCapacityRatio"} + pluginsWithArgs := []string{ + "InterPodAffinity", + "NodeLabel", + "NodeResourcesFit", + "NodeResourcesLeastAllocated", + "NodeResourcesMostAllocated", + "PodTopologySpread", + "RequestedToCapacityRatio", + "VolumeBinding", + } plugins := config.Plugins{ Filter: &config.PluginSet{}, } @@ -510,6 +519,9 @@ func TestNewFrameworkPluginDefaults(t *testing.T) { Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}}, }, "PodTopologySpread": &config.PodTopologySpreadArgs{}, + "VolumeBinding": &config.VolumeBindingArgs{ + BindTimeoutSeconds: 600, + }, }, }, { @@ -545,6 +557,12 @@ func TestNewFrameworkPluginDefaults(t *testing.T) { Resources: []config.ResourceSpec{{Name: "resource", Weight: 2}}, }, }, + { + Name: "VolumeBinding", + Args: &config.VolumeBindingArgs{ + BindTimeoutSeconds: 300, + }, + }, }, wantCfg: map[string]runtime.Object{ "InterPodAffinity": &config.InterPodAffinityArgs{ @@ -564,6 +582,9 @@ func TestNewFrameworkPluginDefaults(t *testing.T) { "RequestedToCapacityRatio": &config.RequestedToCapacityRatioArgs{ Resources: []config.ResourceSpec{{Name: "resource", Weight: 2}}, }, + "VolumeBinding": &config.VolumeBindingArgs{ + BindTimeoutSeconds: 300, + }, }, }, } diff --git a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/register.go b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/register.go index 9a193d790d1..c757e4fb4fa 100644 --- a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/register.go +++ b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/register.go @@ -46,6 +46,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ServiceAffinityArgs{}, &NodeResourcesLeastAllocatedArgs{}, &NodeResourcesMostAllocatedArgs{}, + &VolumeBindingArgs{}, ) return nil } 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 155103531f9..1f81ecf88dd 100644 --- a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go +++ b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go @@ -77,6 +77,8 @@ type KubeSchedulerConfiguration struct { // Duration to wait for a binding operation to complete before timing out // Value must be non-negative integer. The value zero indicates no waiting. // If this value is nil, the default value will be used. + // DEPRECATED: BindTimeoutSeconds is deprecated. To change volume bind + // timeout, configure via plugin args for VolumeBinding. BindTimeoutSeconds *int64 `json:"bindTimeoutSeconds,omitempty"` // PodInitialBackoffSeconds is the initial backoff for unschedulable pods. diff --git a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types_pluginargs.go b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types_pluginargs.go index bf57e45de8c..3776df2f145 100644 --- a/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types_pluginargs.go +++ b/staging/src/k8s.io/kube-scheduler/config/v1alpha2/types_pluginargs.go @@ -173,3 +173,15 @@ type ServiceAffinityArgs struct { // +listType=atomic AntiAffinityLabelsPreference []string `json:"antiAffinityLabelsPreference,omitempty"` } + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VolumeBindingArgs holds arguments used to configure the VolumeBinding plugin. +type VolumeBindingArgs struct { + metav1.TypeMeta `json:",inline"` + + // BindTimeoutSeconds is the timeout in seconds in volume binding operation. + // Value must be non-negative integer. The value zero indicates no waiting. + // If this value is nil, the default value (600) will be used. + BindTimeoutSeconds *int64 `json:"bindTimeoutSeconds,omitempty"` +} 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 c5bfb49220f..064b2f32c12 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 @@ -573,3 +573,33 @@ func (in *UtilizationShapePoint) DeepCopy() *UtilizationShapePoint { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeBindingArgs) DeepCopyInto(out *VolumeBindingArgs) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.BindTimeoutSeconds != nil { + in, out := &in.BindTimeoutSeconds, &out.BindTimeoutSeconds + *out = new(int64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeBindingArgs. +func (in *VolumeBindingArgs) DeepCopy() *VolumeBindingArgs { + if in == nil { + return nil + } + out := new(VolumeBindingArgs) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeBindingArgs) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +}