Skip to content

Commit 2f38e1b

Browse files
authored
Merge pull request kubernetes#91142 from cofyc/fix91139
Add versioned counterparts for VolumeBindingArgs
2 parents 779f875 + 8bbbe62 commit 2f38e1b

File tree

11 files changed

+157
-3
lines changed

11 files changed

+157
-3
lines changed

pkg/scheduler/apis/config/scheme/scheme_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ profiles:
7878
resources:
7979
- name: memory
8080
weight: 1
81+
- name: VolumeBinding
82+
args:
83+
bindTimeoutSeconds: 300
8184
`),
8285
wantProfiles: []config.KubeSchedulerProfile{
8386
{
@@ -128,6 +131,12 @@ profiles:
128131
Resources: []config.ResourceSpec{{Name: "memory", Weight: 1}},
129132
},
130133
},
134+
{
135+
Name: "VolumeBinding",
136+
Args: &config.VolumeBindingArgs{
137+
BindTimeoutSeconds: 300,
138+
},
139+
},
131140
},
132141
},
133142
},
@@ -255,6 +264,8 @@ profiles:
255264
args:
256265
- name: NodeResourcesMostAllocated
257266
args:
267+
- name: VolumeBinding
268+
args:
258269
`),
259270
wantProfiles: []config.KubeSchedulerProfile{
260271
{
@@ -283,6 +294,12 @@ profiles:
283294
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
284295
},
285296
},
297+
{
298+
Name: "VolumeBinding",
299+
Args: &config.VolumeBindingArgs{
300+
BindTimeoutSeconds: 600,
301+
},
302+
},
286303
},
287304
},
288305
},
@@ -334,6 +351,14 @@ func TestCodecsEncodePluginConfig(t *testing.T) {
334351
},
335352
},
336353
},
354+
{
355+
Name: "VolumeBinding",
356+
Args: runtime.RawExtension{
357+
Object: &v1alpha2.VolumeBindingArgs{
358+
BindTimeoutSeconds: pointer.Int64Ptr(300),
359+
},
360+
},
361+
},
337362
{
338363
Name: "RequestedToCapacityRatio",
339364
Args: runtime.RawExtension{
@@ -390,6 +415,11 @@ profiles:
390415
hardPodAffinityWeight: 5
391416
kind: InterPodAffinityArgs
392417
name: InterPodAffinity
418+
- args:
419+
apiVersion: kubescheduler.config.k8s.io/v1alpha2
420+
bindTimeoutSeconds: 300
421+
kind: VolumeBindingArgs
422+
name: VolumeBinding
393423
- args:
394424
apiVersion: kubescheduler.config.k8s.io/v1alpha2
395425
kind: RequestedToCapacityRatioArgs
@@ -431,6 +461,12 @@ profiles:
431461
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}},
432462
},
433463
},
464+
{
465+
Name: "VolumeBinding",
466+
Args: &config.VolumeBindingArgs{
467+
BindTimeoutSeconds: 300,
468+
},
469+
},
434470
{
435471
Name: "OutOfTreePlugin",
436472
Args: &runtime.Unknown{
@@ -480,6 +516,11 @@ profiles:
480516
- Name: cpu
481517
Weight: 1
482518
name: NodeResourcesMostAllocated
519+
- args:
520+
apiVersion: kubescheduler.config.k8s.io/v1alpha2
521+
bindTimeoutSeconds: 300
522+
kind: VolumeBindingArgs
523+
name: VolumeBinding
483524
- args:
484525
foo: bar
485526
name: OutOfTreePlugin

pkg/scheduler/apis/config/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ type KubeSchedulerConfiguration struct {
9090
// nodes will be scored.
9191
PercentageOfNodesToScore int32
9292

93-
// Duration to wait for a binding operation to complete before timing out
93+
// BindTimeoutSeconds is the timeout in seconds in volume binding operation.
9494
// Value must be non-negative integer. The value zero indicates no waiting.
9595
// If this value is nil, the default value will be used.
9696
// DEPRECATED: BindTimeoutSeconds in deprecated.

pkg/scheduler/apis/config/types_pluginargs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ type ServiceAffinityArgs struct {
148148
type VolumeBindingArgs struct {
149149
metav1.TypeMeta
150150

151-
// BindTimeoutSeconds is the timeout in seconds in volume binding.
151+
// BindTimeoutSeconds is the timeout in seconds in volume binding operation.
152+
// Value must be non-negative integer. The value zero indicates no waiting.
153+
// If this value is nil, the default value will be used.
152154
BindTimeoutSeconds int64
153155
}

pkg/scheduler/apis/config/v1alpha2/defaults.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,9 @@ func SetDefaults_RequestedToCapacityRatioArgs(obj *v1alpha2.RequestedToCapacityR
192192
obj.Resources = append(obj.Resources, defaultResourceSpec...)
193193
}
194194
}
195+
196+
func SetDefaults_VolumeBindingArgs(obj *v1alpha2.VolumeBindingArgs) {
197+
if obj.BindTimeoutSeconds == nil {
198+
obj.BindTimeoutSeconds = pointer.Int64Ptr(600)
199+
}
200+
}

pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/scheduler/apis/config/v1alpha2/zz_generated.defaults.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/scheduler/framework/v1alpha1/framework_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,16 @@ func recordingPluginFactory(name string, result map[string]runtime.Object) Plugi
470470

471471
func TestNewFrameworkPluginDefaults(t *testing.T) {
472472
// In-tree plugins that use args.
473-
pluginsWithArgs := []string{"InterPodAffinity", "NodeLabel", "NodeResourcesFit", "NodeResourcesLeastAllocated", "NodeResourcesMostAllocated", "PodTopologySpread", "RequestedToCapacityRatio"}
473+
pluginsWithArgs := []string{
474+
"InterPodAffinity",
475+
"NodeLabel",
476+
"NodeResourcesFit",
477+
"NodeResourcesLeastAllocated",
478+
"NodeResourcesMostAllocated",
479+
"PodTopologySpread",
480+
"RequestedToCapacityRatio",
481+
"VolumeBinding",
482+
}
474483
plugins := config.Plugins{
475484
Filter: &config.PluginSet{},
476485
}
@@ -510,6 +519,9 @@ func TestNewFrameworkPluginDefaults(t *testing.T) {
510519
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
511520
},
512521
"PodTopologySpread": &config.PodTopologySpreadArgs{},
522+
"VolumeBinding": &config.VolumeBindingArgs{
523+
BindTimeoutSeconds: 600,
524+
},
513525
},
514526
},
515527
{
@@ -545,6 +557,12 @@ func TestNewFrameworkPluginDefaults(t *testing.T) {
545557
Resources: []config.ResourceSpec{{Name: "resource", Weight: 2}},
546558
},
547559
},
560+
{
561+
Name: "VolumeBinding",
562+
Args: &config.VolumeBindingArgs{
563+
BindTimeoutSeconds: 300,
564+
},
565+
},
548566
},
549567
wantCfg: map[string]runtime.Object{
550568
"InterPodAffinity": &config.InterPodAffinityArgs{
@@ -564,6 +582,9 @@ func TestNewFrameworkPluginDefaults(t *testing.T) {
564582
"RequestedToCapacityRatio": &config.RequestedToCapacityRatioArgs{
565583
Resources: []config.ResourceSpec{{Name: "resource", Weight: 2}},
566584
},
585+
"VolumeBinding": &config.VolumeBindingArgs{
586+
BindTimeoutSeconds: 300,
587+
},
567588
},
568589
},
569590
}

staging/src/k8s.io/kube-scheduler/config/v1alpha2/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4646
&ServiceAffinityArgs{},
4747
&NodeResourcesLeastAllocatedArgs{},
4848
&NodeResourcesMostAllocatedArgs{},
49+
&VolumeBindingArgs{},
4950
)
5051
return nil
5152
}

staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ type KubeSchedulerConfiguration struct {
7777
// Duration to wait for a binding operation to complete before timing out
7878
// Value must be non-negative integer. The value zero indicates no waiting.
7979
// If this value is nil, the default value will be used.
80+
// DEPRECATED: BindTimeoutSeconds is deprecated. To change volume bind
81+
// timeout, configure via plugin args for VolumeBinding.
8082
BindTimeoutSeconds *int64 `json:"bindTimeoutSeconds,omitempty"`
8183

8284
// PodInitialBackoffSeconds is the initial backoff for unschedulable pods.

staging/src/k8s.io/kube-scheduler/config/v1alpha2/types_pluginargs.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,15 @@ type ServiceAffinityArgs struct {
173173
// +listType=atomic
174174
AntiAffinityLabelsPreference []string `json:"antiAffinityLabelsPreference,omitempty"`
175175
}
176+
177+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
178+
179+
// VolumeBindingArgs holds arguments used to configure the VolumeBinding plugin.
180+
type VolumeBindingArgs struct {
181+
metav1.TypeMeta `json:",inline"`
182+
183+
// BindTimeoutSeconds is the timeout in seconds in volume binding operation.
184+
// Value must be non-negative integer. The value zero indicates no waiting.
185+
// If this value is nil, the default value (600) will be used.
186+
BindTimeoutSeconds *int64 `json:"bindTimeoutSeconds,omitempty"`
187+
}

staging/src/k8s.io/kube-scheduler/config/v1alpha2/zz_generated.deepcopy.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)