Merge pull request #91142 from cofyc/fix91139

Add versioned counterparts for VolumeBindingArgs
This commit is contained in:
Kubernetes Prow Robot 2020-05-25 09:03:12 -07:00 committed by GitHub
commit 2f38e1b130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 157 additions and 3 deletions

View File

@ -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

View File

@ -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.

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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,
},
},
},
}

View File

@ -46,6 +46,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ServiceAffinityArgs{},
&NodeResourcesLeastAllocatedArgs{},
&NodeResourcesMostAllocatedArgs{},
&VolumeBindingArgs{},
)
return nil
}

View File

@ -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.

View File

@ -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"`
}

View File

@ -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
}