From 9819b25a44ef93e2700adce6135fe8b6e82cb762 Mon Sep 17 00:00:00 2001 From: Aldo Culquicondor Date: Tue, 19 May 2020 11:49:36 -0400 Subject: [PATCH] Set weight of PodTopologySpread Score to 2 Signed-off-by: Aldo Culquicondor --- cmd/kube-scheduler/app/server_test.go | 4 ++-- pkg/scheduler/algorithmprovider/registry.go | 5 ++++- pkg/scheduler/algorithmprovider/registry_test.go | 4 ++-- pkg/scheduler/apis/config/testing/compatibility_test.go | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/kube-scheduler/app/server_test.go b/cmd/kube-scheduler/app/server_test.go index b72b0c30817..2e3512d5e2a 100644 --- a/cmd/kube-scheduler/app/server_test.go +++ b/cmd/kube-scheduler/app/server_test.go @@ -189,7 +189,7 @@ profiles: {Name: "NodePreferAvoidPods", Weight: 10000}, {Name: "DefaultPodTopologySpread", Weight: 1}, {Name: "TaintToleration", Weight: 1}, - {Name: "PodTopologySpread", Weight: 1}, + {Name: "PodTopologySpread", Weight: 2}, }, "BindPlugin": {{Name: "DefaultBinder"}}, "ReservePlugin": {{Name: "VolumeBinding"}}, @@ -320,7 +320,7 @@ profiles: {Name: "NodePreferAvoidPods", Weight: 10000}, {Name: "DefaultPodTopologySpread", Weight: 1}, {Name: "TaintToleration", Weight: 1}, - {Name: "PodTopologySpread", Weight: 1}, + {Name: "PodTopologySpread", Weight: 2}, }, "BindPlugin": {{Name: "DefaultBinder"}}, "ReservePlugin": {{Name: "VolumeBinding"}}, diff --git a/pkg/scheduler/algorithmprovider/registry.go b/pkg/scheduler/algorithmprovider/registry.go index 91679af9706..e8898632f8c 100644 --- a/pkg/scheduler/algorithmprovider/registry.go +++ b/pkg/scheduler/algorithmprovider/registry.go @@ -172,7 +172,10 @@ func applyFeatureGates(config *schedulerapi.Plugins) { config.PreFilter.Enabled = append(config.PreFilter.Enabled, f) config.Filter.Enabled = append(config.Filter.Enabled, f) config.PreScore.Enabled = append(config.PreScore.Enabled, f) - s := schedulerapi.Plugin{Name: podtopologyspread.Name, Weight: 1} + // Weight is doubled because: + // - This is a score coming from user preference. + // - It makes its signal comparable to NodeResourcesLeastAllocated. + s := schedulerapi.Plugin{Name: podtopologyspread.Name, Weight: 2} config.Score.Enabled = append(config.Score.Enabled, s) } diff --git a/pkg/scheduler/algorithmprovider/registry_test.go b/pkg/scheduler/algorithmprovider/registry_test.go index 4e7366925bb..6e9a57abe42 100644 --- a/pkg/scheduler/algorithmprovider/registry_test.go +++ b/pkg/scheduler/algorithmprovider/registry_test.go @@ -96,7 +96,7 @@ func TestClusterAutoscalerProvider(t *testing.T) { {Name: nodepreferavoidpods.Name, Weight: 10000}, {Name: defaultpodtopologyspread.Name, Weight: 1}, {Name: tainttoleration.Name, Weight: 1}, - {Name: podtopologyspread.Name, Weight: 1}, + {Name: podtopologyspread.Name, Weight: 2}, }, }, Reserve: &schedulerapi.PluginSet{ @@ -274,7 +274,7 @@ func TestApplyFeatureGates(t *testing.T) { {Name: nodepreferavoidpods.Name, Weight: 10000}, {Name: defaultpodtopologyspread.Name, Weight: 1}, {Name: tainttoleration.Name, Weight: 1}, - {Name: podtopologyspread.Name, Weight: 1}, + {Name: podtopologyspread.Name, Weight: 2}, {Name: noderesources.ResourceLimitsName, Weight: 1}, }, }, diff --git a/pkg/scheduler/apis/config/testing/compatibility_test.go b/pkg/scheduler/apis/config/testing/compatibility_test.go index 43f1e48da2d..04a8ba2f994 100644 --- a/pkg/scheduler/apis/config/testing/compatibility_test.go +++ b/pkg/scheduler/apis/config/testing/compatibility_test.go @@ -1452,7 +1452,7 @@ func TestAlgorithmProviderCompatibility(t *testing.T) { {Name: "NodePreferAvoidPods", Weight: 10000}, {Name: "DefaultPodTopologySpread", Weight: 1}, {Name: "TaintToleration", Weight: 1}, - {Name: "PodTopologySpread", Weight: 1}, + {Name: "PodTopologySpread", Weight: 2}, }, "BindPlugin": {{Name: "DefaultBinder"}}, "ReservePlugin": {{Name: "VolumeBinding"}}, @@ -1520,7 +1520,7 @@ func TestAlgorithmProviderCompatibility(t *testing.T) { {Name: "NodePreferAvoidPods", Weight: 10000}, {Name: "DefaultPodTopologySpread", Weight: 1}, {Name: "TaintToleration", Weight: 1}, - {Name: "PodTopologySpread", Weight: 1}, + {Name: "PodTopologySpread", Weight: 2}, }, "ReservePlugin": {{Name: "VolumeBinding"}}, "UnreservePlugin": {{Name: "VolumeBinding"}}, @@ -1608,7 +1608,7 @@ func TestPluginsConfigurationCompatibility(t *testing.T) { {Name: "NodePreferAvoidPods", Weight: 10000}, {Name: "DefaultPodTopologySpread", Weight: 1}, {Name: "TaintToleration", Weight: 1}, - {Name: "PodTopologySpread", Weight: 1}, + {Name: "PodTopologySpread", Weight: 2}, }, "ReservePlugin": {{Name: "VolumeBinding"}}, "UnreservePlugin": {{Name: "VolumeBinding"}},