Skip to content

Commit 43382b1

Browse files
committed
Switch control from VolumeCapacityPriority to StorageCapacityScoring
The tests and comments have also been updated because while VolumeCapacityPriority preferred a node with the least allocatable, StorageCapacityScoring preferred a node with the maximum allocatable.
1 parent f6ddee9 commit 43382b1

File tree

12 files changed

+60
-78
lines changed

12 files changed

+60
-78
lines changed

cmd/kube-scheduler/app/server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ leaderElection:
226226
name: "default config with an alpha feature enabled",
227227
flags: []string{
228228
"--kubeconfig", configKubeconfig,
229-
"--feature-gates=VolumeCapacityPriority=true",
229+
"--feature-gates=StorageCapacityScoring=true",
230230
},
231231
wantPlugins: map[string]*config.Plugins{
232232
"default-scheduler": defaults.ExpandedPluginsV1,
233233
},
234234
restoreFeatures: map[featuregate.Feature]bool{
235-
features.VolumeCapacityPriority: false,
235+
features.StorageCapacityScoring: false,
236236
},
237237
},
238238
{

pkg/features/kube_features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ const (
681681
// kep: https://kep.k8s.io/4049
682682
//
683683
// Enables scoring nodes by available storage capacity with
684-
// StorageCapacityScoring feature gate (dynamic provisioning only).
684+
// StorageCapacityScoring feature gate.
685685
StorageCapacityScoring featuregate.Feature = "StorageCapacityScoring"
686686

687687
// owner: @gjkim42 @SergeyKanzhelev @matthyx @tzneal

pkg/generated/openapi/zz_generated.openapi.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/scheduler/apis/config/types_pluginargs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ type VolumeBindingArgs struct {
163163
// 1) 0 for 0 utilization
164164
// 2) 10 for 100 utilization
165165
// All points must be sorted in increasing order by utilization.
166-
// +featureGate=VolumeCapacityPriority
166+
// +featureGate=StorageCapacityScoring
167167
// +optional
168168
Shape []UtilizationShapePoint
169169
}

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

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -192,29 +192,16 @@ func SetDefaults_VolumeBindingArgs(obj *configv1.VolumeBindingArgs) {
192192
if obj.BindTimeoutSeconds == nil {
193193
obj.BindTimeoutSeconds = ptr.To[int64](600)
194194
}
195-
if len(obj.Shape) == 0 && feature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority) {
196-
if feature.DefaultFeatureGate.Enabled(features.StorageCapacityScoring) {
197-
obj.Shape = []configv1.UtilizationShapePoint{
198-
{
199-
Utilization: 0,
200-
Score: int32(config.MaxCustomPriorityScore),
201-
},
202-
{
203-
Utilization: 100,
204-
Score: 0,
205-
},
206-
}
207-
} else {
208-
obj.Shape = []configv1.UtilizationShapePoint{
209-
{
210-
Utilization: 0,
211-
Score: 0,
212-
},
213-
{
214-
Utilization: 100,
215-
Score: int32(config.MaxCustomPriorityScore),
216-
},
217-
}
195+
if len(obj.Shape) == 0 && feature.DefaultFeatureGate.Enabled(features.StorageCapacityScoring) {
196+
obj.Shape = []configv1.UtilizationShapePoint{
197+
{
198+
Utilization: 0,
199+
Score: int32(config.MaxCustomPriorityScore),
200+
},
201+
{
202+
Utilization: 100,
203+
Score: 0,
204+
},
218205
}
219206
}
220207
}

pkg/scheduler/apis/config/v1/defaults_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -810,26 +810,26 @@ func TestPluginArgsDefaults(t *testing.T) {
810810
},
811811
},
812812
{
813-
name: "VolumeBindingArgs empty, VolumeCapacityPriority disabled",
813+
name: "VolumeBindingArgs empty, StorageCapacityScoring disabled",
814814
features: map[featuregate.Feature]bool{
815-
features.VolumeCapacityPriority: false,
815+
features.StorageCapacityScoring: false,
816816
},
817817
in: &configv1.VolumeBindingArgs{},
818818
want: &configv1.VolumeBindingArgs{
819819
BindTimeoutSeconds: ptr.To[int64](600),
820820
},
821821
},
822822
{
823-
name: "VolumeBindingArgs empty, VolumeCapacityPriority enabled",
823+
name: "VolumeBindingArgs empty, StorageCapacityScoring enabled",
824824
features: map[featuregate.Feature]bool{
825-
features.VolumeCapacityPriority: true,
825+
features.StorageCapacityScoring: true,
826826
},
827827
in: &configv1.VolumeBindingArgs{},
828828
want: &configv1.VolumeBindingArgs{
829829
BindTimeoutSeconds: ptr.To[int64](600),
830830
Shape: []configv1.UtilizationShapePoint{
831-
{Utilization: 0, Score: 0},
832-
{Utilization: 100, Score: 10},
831+
{Utilization: 0, Score: 10},
832+
{Utilization: 100, Score: 0},
833833
},
834834
},
835835
},

pkg/scheduler/apis/config/validation/validation_pluginargs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ func ValidateNodeAffinityArgs(path *field.Path, args *config.NodeAffinityArgs) e
261261

262262
// VolumeBindingArgsValidationOptions contains the different settings for validation.
263263
type VolumeBindingArgsValidationOptions struct {
264-
AllowVolumeCapacityPriority bool
264+
AllowStorageCapacityScoring bool
265265
}
266266

267267
// ValidateVolumeBindingArgs validates that VolumeBindingArgs are set correctly.
268268
func ValidateVolumeBindingArgs(path *field.Path, args *config.VolumeBindingArgs) error {
269269
return ValidateVolumeBindingArgsWithOptions(path, args, VolumeBindingArgsValidationOptions{
270-
AllowVolumeCapacityPriority: utilfeature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority),
270+
AllowStorageCapacityScoring: utilfeature.DefaultFeatureGate.Enabled(features.StorageCapacityScoring),
271271
})
272272
}
273273

@@ -279,13 +279,13 @@ func ValidateVolumeBindingArgsWithOptions(path *field.Path, args *config.VolumeB
279279
allErrs = append(allErrs, field.Invalid(path.Child("bindTimeoutSeconds"), args.BindTimeoutSeconds, "invalid BindTimeoutSeconds, should not be a negative value"))
280280
}
281281

282-
if opts.AllowVolumeCapacityPriority {
282+
if opts.AllowStorageCapacityScoring {
283283
allErrs = append(allErrs, validateFunctionShape(args.Shape, path.Child("shape"))...)
284284
} else if args.Shape != nil {
285285
// When the feature is off, return an error if the config is not nil.
286286
// This prevents unexpected configuration from taking effect when the
287287
// feature turns on in the future.
288-
allErrs = append(allErrs, field.Invalid(path.Child("shape"), args.Shape, "unexpected field `shape`, remove it or turn on the feature gate VolumeCapacityPriority"))
288+
allErrs = append(allErrs, field.Invalid(path.Child("shape"), args.Shape, "unexpected field `shape`, remove it or turn on the feature gate StorageCapacityScoring"))
289289
}
290290
return allErrs.ToAggregate()
291291
}

pkg/scheduler/apis/config/validation/validation_pluginargs_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,19 +559,19 @@ func TestValidateVolumeBindingArgs(t *testing.T) {
559559
}}),
560560
},
561561
{
562-
name: "[VolumeCapacityPriority=off] shape should be nil when the feature is off",
562+
name: "[StorageCapacityScoring=off] shape should be nil when the feature is off",
563563
features: map[featuregate.Feature]bool{
564-
features.VolumeCapacityPriority: false,
564+
features.StorageCapacityScoring: false,
565565
},
566566
args: config.VolumeBindingArgs{
567567
BindTimeoutSeconds: 10,
568568
Shape: nil,
569569
},
570570
},
571571
{
572-
name: "[VolumeCapacityPriority=off] error if the shape is not nil when the feature is off",
572+
name: "[StorageCapacityScoring=off] error if the shape is not nil when the feature is off",
573573
features: map[featuregate.Feature]bool{
574-
features.VolumeCapacityPriority: false,
574+
features.StorageCapacityScoring: false,
575575
},
576576
args: config.VolumeBindingArgs{
577577
BindTimeoutSeconds: 10,
@@ -586,9 +586,9 @@ func TestValidateVolumeBindingArgs(t *testing.T) {
586586
}}),
587587
},
588588
{
589-
name: "[VolumeCapacityPriority=on] shape should not be empty",
589+
name: "[StorageCapacityScoring=on] shape should not be empty",
590590
features: map[featuregate.Feature]bool{
591-
features.VolumeCapacityPriority: true,
591+
features.StorageCapacityScoring: true,
592592
},
593593
args: config.VolumeBindingArgs{
594594
BindTimeoutSeconds: 10,
@@ -600,9 +600,9 @@ func TestValidateVolumeBindingArgs(t *testing.T) {
600600
}}),
601601
},
602602
{
603-
name: "[VolumeCapacityPriority=on] shape points must be sorted in increasing order",
603+
name: "[StorageCapacityScoring=on] shape points must be sorted in increasing order",
604604
features: map[featuregate.Feature]bool{
605-
features.VolumeCapacityPriority: true,
605+
features.StorageCapacityScoring: true,
606606
},
607607
args: config.VolumeBindingArgs{
608608
BindTimeoutSeconds: 10,
@@ -618,9 +618,9 @@ func TestValidateVolumeBindingArgs(t *testing.T) {
618618
}}),
619619
},
620620
{
621-
name: "[VolumeCapacityPriority=on] shape point: invalid utilization and score",
621+
name: "[StorageCapacityScoring=on] shape point: invalid utilization and score",
622622
features: map[featuregate.Feature]bool{
623-
features.VolumeCapacityPriority: true,
623+
features.StorageCapacityScoring: true,
624624
},
625625
args: config.VolumeBindingArgs{
626626
BindTimeoutSeconds: 10,

pkg/scheduler/framework/plugins/volumebinding/volume_binding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ func New(ctx context.Context, plArgs runtime.Object, fh framework.Handle, fts fe
592592
return nil, fmt.Errorf("want args to be of type VolumeBindingArgs, got %T", plArgs)
593593
}
594594
if err := validation.ValidateVolumeBindingArgsWithOptions(nil, args, validation.VolumeBindingArgsValidationOptions{
595-
AllowVolumeCapacityPriority: fts.EnableVolumeCapacityPriority,
595+
AllowStorageCapacityScoring: fts.EnableStorageCapacityScoring,
596596
}); err != nil {
597597
return nil, err
598598
}
@@ -610,7 +610,7 @@ func New(ctx context.Context, plArgs runtime.Object, fh framework.Handle, fts fe
610610

611611
// build score function
612612
var scorer volumeCapacityScorer
613-
if fts.EnableVolumeCapacityPriority {
613+
if fts.EnableStorageCapacityScoring {
614614
shape := make(helper.FunctionShape, 0, len(args.Shape))
615615
for _, point := range args.Shape {
616616
shape = append(shape, helper.FunctionShapePoint{

pkg/scheduler/framework/plugins/volumebinding/volume_binding_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func TestVolumeBinding(t *testing.T) {
327327
withNodeAffinity(map[string][]string{v1.LabelHostname: {"node-b"}}).PersistentVolume,
328328
},
329329
fts: feature.Features{
330-
EnableVolumeCapacityPriority: true,
330+
EnableStorageCapacityScoring: true,
331331
},
332332
wantPreFilterStatus: nil,
333333
wantStateAfterPreFilter: &stateData{
@@ -417,7 +417,7 @@ func TestVolumeBinding(t *testing.T) {
417417
withNodeAffinity(map[string][]string{v1.LabelHostname: {"node-b"}}).PersistentVolume,
418418
},
419419
fts: feature.Features{
420-
EnableVolumeCapacityPriority: true,
420+
EnableStorageCapacityScoring: true,
421421
},
422422
wantPreFilterStatus: nil,
423423
wantStateAfterPreFilter: &stateData{
@@ -536,7 +536,7 @@ func TestVolumeBinding(t *testing.T) {
536536
}).PersistentVolume,
537537
},
538538
fts: feature.Features{
539-
EnableVolumeCapacityPriority: true,
539+
EnableStorageCapacityScoring: true,
540540
},
541541
wantPreFilterStatus: nil,
542542
wantStateAfterPreFilter: &stateData{
@@ -654,7 +654,7 @@ func TestVolumeBinding(t *testing.T) {
654654
}).PersistentVolume,
655655
},
656656
fts: feature.Features{
657-
EnableVolumeCapacityPriority: true,
657+
EnableStorageCapacityScoring: true,
658658
},
659659
args: &config.VolumeBindingArgs{
660660
BindTimeoutSeconds: 300,
@@ -750,7 +750,6 @@ func TestVolumeBinding(t *testing.T) {
750750
makeCapacity("node-c", waitSCWithStorageCapacity.Name, makeNode("node-c").withLabel(nodeLabelKey, "node-c").Node, "10Gi", ""),
751751
},
752752
fts: feature.Features{
753-
EnableVolumeCapacityPriority: true,
754753
EnableStorageCapacityScoring: true,
755754
},
756755
wantPreFilterStatus: nil,
@@ -807,7 +806,6 @@ func TestVolumeBinding(t *testing.T) {
807806
makeCapacity("node-c", waitSCWithStorageCapacity.Name, makeNode("node-c").withLabel(nodeLabelKey, "node-c").Node, "10Gi", ""),
808807
},
809808
fts: feature.Features{
810-
EnableVolumeCapacityPriority: true,
811809
EnableStorageCapacityScoring: true,
812810
},
813811
wantPreFilterStatus: nil,
@@ -863,7 +861,6 @@ func TestVolumeBinding(t *testing.T) {
863861
makeCapacity("node-a", waitSCWithStorageCapacity.Name, makeNode("node-a").withLabel(nodeLabelKey, "node-a").Node, "100Gi", ""),
864862
},
865863
fts: feature.Features{
866-
EnableVolumeCapacityPriority: true,
867864
EnableStorageCapacityScoring: true,
868865
},
869866
wantPreFilterStatus: nil,
@@ -902,7 +899,6 @@ func TestVolumeBinding(t *testing.T) {
902899
makeCapacity("node-c", waitSCWithStorageCapacity.Name, makeNode("node-c").withLabel(nodeLabelKey, "node-c").Node, "10Gi", ""),
903900
},
904901
fts: feature.Features{
905-
EnableVolumeCapacityPriority: true,
906902
EnableStorageCapacityScoring: true,
907903
},
908904
wantPreFilterStatus: nil,
@@ -944,7 +940,6 @@ func TestVolumeBinding(t *testing.T) {
944940
makeCapacity("node-c", waitSCWithStorageCapacity.Name, makeNode("node-c").withLabel(nodeLabelKey, "node-c").Node, "10Gi", ""),
945941
},
946942
fts: feature.Features{
947-
EnableVolumeCapacityPriority: true,
948943
EnableStorageCapacityScoring: true,
949944
},
950945
args: &config.VolumeBindingArgs{
@@ -1006,7 +1001,7 @@ func TestVolumeBinding(t *testing.T) {
10061001
args = &config.VolumeBindingArgs{
10071002
BindTimeoutSeconds: 300,
10081003
}
1009-
if item.fts.EnableVolumeCapacityPriority {
1004+
if item.fts.EnableStorageCapacityScoring {
10101005
args.Shape = defaultShapePoint
10111006
}
10121007
}

0 commit comments

Comments
 (0)