Skip to content

Commit 9819b25

Browse files
Set weight of PodTopologySpread Score to 2
Signed-off-by: Aldo Culquicondor <[email protected]>
1 parent 6c9aab2 commit 9819b25

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

cmd/kube-scheduler/app/server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ profiles:
189189
{Name: "NodePreferAvoidPods", Weight: 10000},
190190
{Name: "DefaultPodTopologySpread", Weight: 1},
191191
{Name: "TaintToleration", Weight: 1},
192-
{Name: "PodTopologySpread", Weight: 1},
192+
{Name: "PodTopologySpread", Weight: 2},
193193
},
194194
"BindPlugin": {{Name: "DefaultBinder"}},
195195
"ReservePlugin": {{Name: "VolumeBinding"}},
@@ -320,7 +320,7 @@ profiles:
320320
{Name: "NodePreferAvoidPods", Weight: 10000},
321321
{Name: "DefaultPodTopologySpread", Weight: 1},
322322
{Name: "TaintToleration", Weight: 1},
323-
{Name: "PodTopologySpread", Weight: 1},
323+
{Name: "PodTopologySpread", Weight: 2},
324324
},
325325
"BindPlugin": {{Name: "DefaultBinder"}},
326326
"ReservePlugin": {{Name: "VolumeBinding"}},

pkg/scheduler/algorithmprovider/registry.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ func applyFeatureGates(config *schedulerapi.Plugins) {
172172
config.PreFilter.Enabled = append(config.PreFilter.Enabled, f)
173173
config.Filter.Enabled = append(config.Filter.Enabled, f)
174174
config.PreScore.Enabled = append(config.PreScore.Enabled, f)
175-
s := schedulerapi.Plugin{Name: podtopologyspread.Name, Weight: 1}
175+
// Weight is doubled because:
176+
// - This is a score coming from user preference.
177+
// - It makes its signal comparable to NodeResourcesLeastAllocated.
178+
s := schedulerapi.Plugin{Name: podtopologyspread.Name, Weight: 2}
176179
config.Score.Enabled = append(config.Score.Enabled, s)
177180
}
178181

pkg/scheduler/algorithmprovider/registry_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func TestClusterAutoscalerProvider(t *testing.T) {
9696
{Name: nodepreferavoidpods.Name, Weight: 10000},
9797
{Name: defaultpodtopologyspread.Name, Weight: 1},
9898
{Name: tainttoleration.Name, Weight: 1},
99-
{Name: podtopologyspread.Name, Weight: 1},
99+
{Name: podtopologyspread.Name, Weight: 2},
100100
},
101101
},
102102
Reserve: &schedulerapi.PluginSet{
@@ -274,7 +274,7 @@ func TestApplyFeatureGates(t *testing.T) {
274274
{Name: nodepreferavoidpods.Name, Weight: 10000},
275275
{Name: defaultpodtopologyspread.Name, Weight: 1},
276276
{Name: tainttoleration.Name, Weight: 1},
277-
{Name: podtopologyspread.Name, Weight: 1},
277+
{Name: podtopologyspread.Name, Weight: 2},
278278
{Name: noderesources.ResourceLimitsName, Weight: 1},
279279
},
280280
},

pkg/scheduler/apis/config/testing/compatibility_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ func TestAlgorithmProviderCompatibility(t *testing.T) {
14521452
{Name: "NodePreferAvoidPods", Weight: 10000},
14531453
{Name: "DefaultPodTopologySpread", Weight: 1},
14541454
{Name: "TaintToleration", Weight: 1},
1455-
{Name: "PodTopologySpread", Weight: 1},
1455+
{Name: "PodTopologySpread", Weight: 2},
14561456
},
14571457
"BindPlugin": {{Name: "DefaultBinder"}},
14581458
"ReservePlugin": {{Name: "VolumeBinding"}},
@@ -1520,7 +1520,7 @@ func TestAlgorithmProviderCompatibility(t *testing.T) {
15201520
{Name: "NodePreferAvoidPods", Weight: 10000},
15211521
{Name: "DefaultPodTopologySpread", Weight: 1},
15221522
{Name: "TaintToleration", Weight: 1},
1523-
{Name: "PodTopologySpread", Weight: 1},
1523+
{Name: "PodTopologySpread", Weight: 2},
15241524
},
15251525
"ReservePlugin": {{Name: "VolumeBinding"}},
15261526
"UnreservePlugin": {{Name: "VolumeBinding"}},
@@ -1608,7 +1608,7 @@ func TestPluginsConfigurationCompatibility(t *testing.T) {
16081608
{Name: "NodePreferAvoidPods", Weight: 10000},
16091609
{Name: "DefaultPodTopologySpread", Weight: 1},
16101610
{Name: "TaintToleration", Weight: 1},
1611-
{Name: "PodTopologySpread", Weight: 1},
1611+
{Name: "PodTopologySpread", Weight: 2},
16121612
},
16131613
"ReservePlugin": {{Name: "VolumeBinding"}},
16141614
"UnreservePlugin": {{Name: "VolumeBinding"}},

0 commit comments

Comments
 (0)