Skip to content

Commit 3fe372c

Browse files
authored
Merge pull request kubernetes#95631 from alculquicondor/enable-default-spreading
Graduate DefaultPodTopologySpread to beta
2 parents 2be8f3c + 87c8349 commit 3fe372c

File tree

13 files changed

+76
-119
lines changed

13 files changed

+76
-119
lines changed

cmd/kube-scheduler/app/server_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ profiles:
186186
{Name: "InterPodAffinity"},
187187
{Name: "PodTopologySpread"},
188188
{Name: "TaintToleration"},
189-
{Name: "SelectorSpread"},
190189
},
191190
"ScorePlugin": {
192191
{Name: "NodeResourcesBalancedAllocation", Weight: 1},
@@ -197,7 +196,6 @@ profiles:
197196
{Name: "NodePreferAvoidPods", Weight: 10000},
198197
{Name: "PodTopologySpread", Weight: 2},
199198
{Name: "TaintToleration", Weight: 1},
200-
{Name: "SelectorSpread", Weight: 1},
201199
},
202200
"BindPlugin": {{Name: "DefaultBinder"}},
203201
"ReservePlugin": {{Name: "VolumeBinding"}},
@@ -316,7 +314,6 @@ profiles:
316314
{Name: "InterPodAffinity"},
317315
{Name: "PodTopologySpread"},
318316
{Name: "TaintToleration"},
319-
{Name: "SelectorSpread"},
320317
},
321318
"ScorePlugin": {
322319
{Name: "NodeResourcesBalancedAllocation", Weight: 1},
@@ -327,7 +324,6 @@ profiles:
327324
{Name: "NodePreferAvoidPods", Weight: 10000},
328325
{Name: "PodTopologySpread", Weight: 2},
329326
{Name: "TaintToleration", Weight: 1},
330-
{Name: "SelectorSpread", Weight: 1},
331327
},
332328
"BindPlugin": {{Name: "DefaultBinder"}},
333329
"ReservePlugin": {{Name: "VolumeBinding"}},

pkg/features/kube_features.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ const (
296296
CSIStorageCapacity featuregate.Feature = "CSIStorageCapacity"
297297

298298
// owner: @alculquicondor
299-
// alpha: v1.19
299+
// beta: v1.20
300300
//
301301
// Enables the use of PodTopologySpread scheduling plugin to do default
302302
// spreading and disables legacy SelectorSpread plugin.
@@ -733,7 +733,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
733733
HugePageStorageMediumSize: {Default: true, PreRelease: featuregate.Beta},
734734
ExternalPolicyForExternalIP: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.22
735735
AnyVolumeDataSource: {Default: false, PreRelease: featuregate.Alpha},
736-
DefaultPodTopologySpread: {Default: false, PreRelease: featuregate.Alpha},
736+
DefaultPodTopologySpread: {Default: true, PreRelease: featuregate.Beta},
737737
SetHostnameAsFQDN: {Default: true, PreRelease: featuregate.Beta},
738738
WinOverlay: {Default: true, PreRelease: featuregate.Beta},
739739
WinDSR: {Default: false, PreRelease: featuregate.Alpha},

pkg/scheduler/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ go_test(
6969
"//pkg/scheduler/framework/plugins/nodelabel:go_default_library",
7070
"//pkg/scheduler/framework/plugins/nodeports:go_default_library",
7171
"//pkg/scheduler/framework/plugins/noderesources:go_default_library",
72+
"//pkg/scheduler/framework/plugins/podtopologyspread:go_default_library",
7273
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
7374
"//pkg/scheduler/framework/plugins/serviceaffinity:go_default_library",
7475
"//pkg/scheduler/framework/plugins/volumebinding:go_default_library",

pkg/scheduler/algorithmprovider/registry_test.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ import (
2020
"testing"
2121

2222
"github.com/google/go-cmp/cmp"
23+
"k8s.io/apiserver/pkg/util/feature"
2324
"k8s.io/component-base/featuregate"
24-
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption"
25-
26-
utilfeature "k8s.io/apiserver/pkg/util/feature"
2725
featuregatetesting "k8s.io/component-base/featuregate/testing"
2826
"k8s.io/kubernetes/pkg/features"
2927
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
3028
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultbinder"
29+
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption"
3130
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/imagelocality"
3231
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/interpodaffinity"
3332
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodeaffinity"
@@ -91,7 +90,6 @@ func TestClusterAutoscalerProvider(t *testing.T) {
9190
{Name: interpodaffinity.Name},
9291
{Name: podtopologyspread.Name},
9392
{Name: tainttoleration.Name},
94-
{Name: selectorspread.Name},
9593
},
9694
},
9795
Score: &schedulerapi.PluginSet{
@@ -104,7 +102,6 @@ func TestClusterAutoscalerProvider(t *testing.T) {
104102
{Name: nodepreferavoidpods.Name, Weight: 10000},
105103
{Name: podtopologyspread.Name, Weight: 2},
106104
{Name: tainttoleration.Name, Weight: 1},
107-
{Name: selectorspread.Name, Weight: 1},
108105
},
109106
},
110107
Reserve: &schedulerapi.PluginSet{
@@ -134,7 +131,7 @@ func TestClusterAutoscalerProvider(t *testing.T) {
134131
func TestApplyFeatureGates(t *testing.T) {
135132
tests := []struct {
136133
name string
137-
feature featuregate.Feature
134+
features map[featuregate.Feature]bool
138135
wantConfig *schedulerapi.Plugins
139136
}{
140137
{
@@ -183,7 +180,6 @@ func TestApplyFeatureGates(t *testing.T) {
183180
{Name: interpodaffinity.Name},
184181
{Name: podtopologyspread.Name},
185182
{Name: tainttoleration.Name},
186-
{Name: selectorspread.Name},
187183
},
188184
},
189185
Score: &schedulerapi.PluginSet{
@@ -196,7 +192,6 @@ func TestApplyFeatureGates(t *testing.T) {
196192
{Name: nodepreferavoidpods.Name, Weight: 10000},
197193
{Name: podtopologyspread.Name, Weight: 2},
198194
{Name: tainttoleration.Name, Weight: 1},
199-
{Name: selectorspread.Name, Weight: 1},
200195
},
201196
},
202197
Reserve: &schedulerapi.PluginSet{
@@ -217,8 +212,10 @@ func TestApplyFeatureGates(t *testing.T) {
217212
},
218213
},
219214
{
220-
name: "NewDefaultPodTopologySpread enabled",
221-
feature: features.DefaultPodTopologySpread,
215+
name: "DefaultPodTopologySpread disabled",
216+
features: map[featuregate.Feature]bool{
217+
features.DefaultPodTopologySpread: false,
218+
},
222219
wantConfig: &schedulerapi.Plugins{
223220
QueueSort: &schedulerapi.PluginSet{
224221
Enabled: []schedulerapi.Plugin{
@@ -263,6 +260,7 @@ func TestApplyFeatureGates(t *testing.T) {
263260
{Name: interpodaffinity.Name},
264261
{Name: podtopologyspread.Name},
265262
{Name: tainttoleration.Name},
263+
{Name: selectorspread.Name},
266264
},
267265
},
268266
Score: &schedulerapi.PluginSet{
@@ -275,6 +273,7 @@ func TestApplyFeatureGates(t *testing.T) {
275273
{Name: nodepreferavoidpods.Name, Weight: 10000},
276274
{Name: podtopologyspread.Name, Weight: 2},
277275
{Name: tainttoleration.Name, Weight: 1},
276+
{Name: selectorspread.Name, Weight: 1},
278277
},
279278
},
280279
Reserve: &schedulerapi.PluginSet{
@@ -298,8 +297,8 @@ func TestApplyFeatureGates(t *testing.T) {
298297

299298
for _, test := range tests {
300299
t.Run(test.name, func(t *testing.T) {
301-
if test.feature != "" {
302-
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, test.feature, true)()
300+
for k, v := range test.features {
301+
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, k, v)()
303302
}
304303

305304
r := NewRegistry()

pkg/scheduler/apis/config/scheme/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ go_test(
3838
"//staging/src/k8s.io/api/core/v1:go_default_library",
3939
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
4040
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
41-
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
42-
"//staging/src/k8s.io/component-base/featuregate:go_default_library",
43-
"//staging/src/k8s.io/component-base/featuregate/testing:go_default_library",
4441
"//staging/src/k8s.io/kube-scheduler/config/v1beta1:go_default_library",
4542
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
4643
"//vendor/k8s.io/utils/pointer:go_default_library",

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import (
2424
corev1 "k8s.io/api/core/v1"
2525
"k8s.io/apimachinery/pkg/runtime"
2626
"k8s.io/apimachinery/pkg/runtime/schema"
27-
"k8s.io/apiserver/pkg/util/feature"
28-
"k8s.io/component-base/featuregate"
29-
featuregatetesting "k8s.io/component-base/featuregate/testing"
3027
"k8s.io/kube-scheduler/config/v1beta1"
3128
"k8s.io/kubernetes/pkg/scheduler/apis/config"
3229
"k8s.io/utils/pointer"
@@ -39,7 +36,6 @@ func TestCodecsDecodePluginConfig(t *testing.T) {
3936
testCases := []struct {
4037
name string
4138
data []byte
42-
feature featuregate.Feature
4339
wantErr string
4440
wantProfiles []config.KubeSchedulerProfile
4541
}{
@@ -302,7 +298,7 @@ profiles:
302298
{
303299
Name: "PodTopologySpread",
304300
Args: &config.PodTopologySpreadArgs{
305-
DefaultingType: config.ListDefaulting,
301+
DefaultingType: config.SystemDefaulting,
306302
},
307303
},
308304
},
@@ -313,9 +309,6 @@ profiles:
313309
decoder := Codecs.UniversalDecoder()
314310
for _, tt := range testCases {
315311
t.Run(tt.name, func(t *testing.T) {
316-
if tt.feature != "" {
317-
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, tt.feature, true)()
318-
}
319312
obj, gvk, err := decoder.Decode(tt.data, nil, nil)
320313
if err != nil {
321314
if tt.wantErr != err.Error() {

0 commit comments

Comments
 (0)