Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graduate default pod topology spread to ga #108278

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 3 additions & 10 deletions cmd/kube-scheduler/app/server_test.go
Expand Up @@ -39,7 +39,6 @@ import (
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/scheduler/apis/config"
"k8s.io/kubernetes/pkg/scheduler/apis/config/testing/defaults"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/names"
)

func TestSetup(t *testing.T) {
Expand Down Expand Up @@ -217,10 +216,10 @@ leaderElection:
wantLeaderElection *componentbaseconfig.LeaderElectionConfiguration
}{
{
name: "default config with an alpha feature enabled and an beta feature disabled",
name: "default config with an alpha feature enabled",
flags: []string{
"--kubeconfig", configKubeconfig,
"--feature-gates=VolumeCapacityPriority=true,DefaultPodTopologySpread=false",
"--feature-gates=VolumeCapacityPriority=true",
},
wantPlugins: map[string]*config.Plugins{
"default-scheduler": func() *config.Plugins {
Expand All @@ -235,17 +234,11 @@ leaderElection:
PreBind: defaults.ExpandedPluginsV1beta3.PreBind,
Reserve: defaults.ExpandedPluginsV1beta3.Reserve,
}
plugins.PreScore.Enabled = append(plugins.PreScore.Enabled, config.Plugin{Name: names.SelectorSpread, Weight: 0})
plugins.Score.Enabled = append(
plugins.Score.Enabled,
config.Plugin{Name: names.SelectorSpread, Weight: 1},
)
return plugins
}(),
},
restoreFeatures: map[featuregate.Feature]bool{
features.VolumeCapacityPriority: false,
features.DefaultPodTopologySpread: true,
features.VolumeCapacityPriority: false,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/features/kube_features.go
Expand Up @@ -888,7 +888,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
DaemonSetUpdateSurge: {Default: true, PreRelease: featuregate.Beta}, // on by default in 1.22
DownwardAPIHugePages: {Default: true, PreRelease: featuregate.Beta}, // on by default in 1.22
AnyVolumeDataSource: {Default: false, PreRelease: featuregate.Alpha},
DefaultPodTopologySpread: {Default: true, PreRelease: featuregate.Beta},
DefaultPodTopologySpread: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26
WinOverlay: {Default: true, PreRelease: featuregate.Beta},
WinDSR: {Default: false, PreRelease: featuregate.Alpha},
DisableAcceleratorUsageMetrics: {Default: true, PreRelease: featuregate.Beta},
Expand Down
3 changes: 1 addition & 2 deletions pkg/scheduler/apis/config/types_pluginargs.go
Expand Up @@ -105,8 +105,7 @@ type PodTopologySpreadArgs struct {
// Nodes and Zones.
// - "List": Use constraints defined in .defaultConstraints.
//
// Defaults to "List" if feature gate DefaultPodTopologySpread is disabled
// and to "System" if enabled.
// Defaults to "System".
// +optional
DefaultingType PodTopologySpreadConstraintsDefaulting
}
Expand Down
10 changes: 0 additions & 10 deletions pkg/scheduler/apis/config/v1beta2/default_plugins.go
Expand Up @@ -116,16 +116,6 @@ func applyFeatureGates(config *v1beta2.Plugins) {
if utilfeature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority) {
config.Score.Enabled = append(config.Score.Enabled, v1beta2.Plugin{Name: names.VolumeBinding, Weight: pointer.Int32Ptr(1)})
}

if !utilfeature.DefaultFeatureGate.Enabled(features.DefaultPodTopologySpread) {
// When feature is enabled, the default spreading is done by
// PodTopologySpread plugin, which is enabled by default.
klog.InfoS("Registering SelectorSpread plugin")
s := v1beta2.Plugin{Name: names.SelectorSpread}
config.PreScore.Enabled = append(config.PreScore.Enabled, s)
s.Weight = pointer.Int32Ptr(1)
config.Score.Enabled = append(config.Score.Enabled, s)
}
}

// mergePlugins merges the custom set into the given default one, handling disabled sets.
Expand Down
85 changes: 0 additions & 85 deletions pkg/scheduler/apis/config/v1beta2/default_plugins_test.go
Expand Up @@ -24,7 +24,6 @@ import (
"k8s.io/component-base/featuregate"
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/kube-scheduler/config/v1beta2"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/names"
"k8s.io/utils/pointer"
)
Expand Down Expand Up @@ -114,90 +113,6 @@ func TestApplyFeatureGates(t *testing.T) {
},
},
},
{
name: "DefaultPodTopologySpread disabled",
features: map[featuregate.Feature]bool{
features.DefaultPodTopologySpread: false,
},
wantConfig: &v1beta2.Plugins{
QueueSort: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.PrioritySort},
},
},
PreFilter: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.NodeResourcesFit},
{Name: names.NodePorts},
{Name: names.VolumeRestrictions},
{Name: names.PodTopologySpread},
{Name: names.InterPodAffinity},
{Name: names.VolumeBinding},
{Name: names.NodeAffinity},
},
},
Filter: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.NodeUnschedulable},
{Name: names.NodeName},
{Name: names.TaintToleration},
{Name: names.NodeAffinity},
{Name: names.NodePorts},
{Name: names.NodeResourcesFit},
{Name: names.VolumeRestrictions},
{Name: names.EBSLimits},
{Name: names.GCEPDLimits},
{Name: names.NodeVolumeLimits},
{Name: names.AzureDiskLimits},
{Name: names.VolumeBinding},
{Name: names.VolumeZone},
{Name: names.PodTopologySpread},
{Name: names.InterPodAffinity},
},
},
PostFilter: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.DefaultPreemption},
},
},
PreScore: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.InterPodAffinity},
{Name: names.PodTopologySpread},
{Name: names.TaintToleration},
{Name: names.NodeAffinity},
{Name: names.SelectorSpread},
},
},
Score: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)},
{Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)},
{Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(1)},
{Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)},
{Name: names.NodeAffinity, Weight: pointer.Int32Ptr(1)},
{Name: names.PodTopologySpread, Weight: pointer.Int32Ptr(2)},
{Name: names.TaintToleration, Weight: pointer.Int32Ptr(1)},
{Name: names.SelectorSpread, Weight: pointer.Int32Ptr(1)},
},
},
Reserve: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.VolumeBinding},
},
},
PreBind: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.VolumeBinding},
},
},
Bind: v1beta2.PluginSet{
Enabled: []v1beta2.Plugin{
{Name: names.DefaultBinder},
},
},
},
},
}

for _, test := range tests {
Expand Down
8 changes: 1 addition & 7 deletions pkg/scheduler/apis/config/v1beta2/defaults.go
Expand Up @@ -227,14 +227,8 @@ func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta2.NodeResourcesB
}

func SetDefaults_PodTopologySpreadArgs(obj *v1beta2.PodTopologySpreadArgs) {
if feature.DefaultFeatureGate.Enabled(features.DefaultPodTopologySpread) {
if obj.DefaultingType == "" {
obj.DefaultingType = v1beta2.SystemDefaulting
}
return
}
if obj.DefaultingType == "" {
obj.DefaultingType = v1beta2.ListDefaulting
obj.DefaultingType = v1beta2.SystemDefaulting
}
}

Expand Down
10 changes: 0 additions & 10 deletions pkg/scheduler/apis/config/v1beta2/defaults_test.go
Expand Up @@ -586,16 +586,6 @@ func TestPluginArgsDefaults(t *testing.T) {
DefaultingType: v1beta2.SystemDefaulting,
},
},
{
name: "PodTopologySpreadArgs empty, DefaultPodTopologySpread feature disabled",
features: map[featuregate.Feature]bool{
features.DefaultPodTopologySpread: false,
},
in: &v1beta2.PodTopologySpreadArgs{},
want: &v1beta2.PodTopologySpreadArgs{
DefaultingType: v1beta2.ListDefaulting,
},
},
{
name: "NodeResourcesFitArgs not set",
in: &v1beta2.NodeResourcesFitArgs{},
Expand Down
13 changes: 0 additions & 13 deletions pkg/scheduler/apis/config/v1beta3/default_plugins.go
Expand Up @@ -18,10 +18,8 @@ package v1beta3

import (
"k8s.io/apimachinery/pkg/util/sets"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog/v2"
"k8s.io/kube-scheduler/config/v1beta3"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/names"
"k8s.io/utils/pointer"
)
Expand Down Expand Up @@ -54,21 +52,10 @@ func getDefaultPlugins() *v1beta3.Plugins {
},
},
}
applyFeatureGates(plugins)

return plugins
}

func applyFeatureGates(config *v1beta3.Plugins) {
if !utilfeature.DefaultFeatureGate.Enabled(features.DefaultPodTopologySpread) {
// When feature is enabled, the default spreading is done by
// PodTopologySpread plugin, which is enabled by default.
klog.InfoS("Registering SelectorSpread plugin")
s := v1beta3.Plugin{Name: names.SelectorSpread, Weight: pointer.Int32Ptr(1)}
config.MultiPoint.Enabled = append(config.MultiPoint.Enabled, s)
}
}

// mergePlugins merges the custom set into the given default one, handling disabled sets.
func mergePlugins(defaultPlugins, customPlugins *v1beta3.Plugins) *v1beta3.Plugins {
if customPlugins == nil {
Expand Down
34 changes: 0 additions & 34 deletions pkg/scheduler/apis/config/v1beta3/default_plugins_test.go
Expand Up @@ -24,7 +24,6 @@ import (
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/component-base/featuregate"
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/names"
"k8s.io/utils/pointer"
)
Expand Down Expand Up @@ -64,39 +63,6 @@ func TestApplyFeatureGates(t *testing.T) {
},
},
},
{
name: "DefaultPodTopologySpread disabled",
features: map[featuregate.Feature]bool{
features.DefaultPodTopologySpread: false,
},
wantConfig: &v1beta3.Plugins{
MultiPoint: v1beta3.PluginSet{
Enabled: []v1beta3.Plugin{
{Name: names.PrioritySort},
{Name: names.NodeUnschedulable},
{Name: names.NodeName},
{Name: names.TaintToleration, Weight: pointer.Int32(3)},
{Name: names.NodeAffinity, Weight: pointer.Int32(2)},
{Name: names.NodePorts},
{Name: names.NodeResourcesFit, Weight: pointer.Int32(1)},
{Name: names.VolumeRestrictions},
{Name: names.EBSLimits},
{Name: names.GCEPDLimits},
{Name: names.NodeVolumeLimits},
{Name: names.AzureDiskLimits},
{Name: names.VolumeBinding},
{Name: names.VolumeZone},
{Name: names.PodTopologySpread, Weight: pointer.Int32(2)},
{Name: names.InterPodAffinity, Weight: pointer.Int32(2)},
{Name: names.DefaultPreemption},
{Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)},
{Name: names.ImageLocality, Weight: pointer.Int32(1)},
{Name: names.DefaultBinder},
{Name: names.SelectorSpread, Weight: pointer.Int32(1)},
},
},
},
},
}

for _, test := range tests {
Expand Down
8 changes: 1 addition & 7 deletions pkg/scheduler/apis/config/v1beta3/defaults.go
Expand Up @@ -227,14 +227,8 @@ func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta3.NodeResourcesB
}

func SetDefaults_PodTopologySpreadArgs(obj *v1beta3.PodTopologySpreadArgs) {
if feature.DefaultFeatureGate.Enabled(features.DefaultPodTopologySpread) {
if obj.DefaultingType == "" {
obj.DefaultingType = v1beta3.SystemDefaulting
}
return
}
if obj.DefaultingType == "" {
obj.DefaultingType = v1beta3.ListDefaulting
obj.DefaultingType = v1beta3.SystemDefaulting
}
}

Expand Down
10 changes: 0 additions & 10 deletions pkg/scheduler/apis/config/v1beta3/defaults_test.go
Expand Up @@ -581,16 +581,6 @@ func TestPluginArgsDefaults(t *testing.T) {
DefaultingType: v1beta3.SystemDefaulting,
},
},
{
name: "PodTopologySpreadArgs empty, DefaultPodTopologySpread feature disabled",
features: map[featuregate.Feature]bool{
features.DefaultPodTopologySpread: false,
},
in: &v1beta3.PodTopologySpreadArgs{},
want: &v1beta3.PodTopologySpreadArgs{
DefaultingType: v1beta3.ListDefaulting,
},
},
{
name: "NodeResourcesFitArgs not set",
in: &v1beta3.NodeResourcesFitArgs{},
Expand Down
Expand Up @@ -110,8 +110,7 @@ type PodTopologySpreadArgs struct {
// Nodes and Zones.
// - "List": Use constraints defined in .defaultConstraints.
//
// Defaults to "List" if feature gate DefaultPodTopologySpread is disabled
// and to "System" if enabled.
// Defaults to "System".
// +optional
DefaultingType PodTopologySpreadConstraintsDefaulting `json:"defaultingType,omitempty"`
}
Expand Down
Expand Up @@ -110,8 +110,7 @@ type PodTopologySpreadArgs struct {
// Nodes and Zones.
// - "List": Use constraints defined in .defaultConstraints.
//
// Defaults to "List" if feature gate DefaultPodTopologySpread is disabled
// and to "System" if enabled.
// Defaults to "System".
// +optional
DefaultingType PodTopologySpreadConstraintsDefaulting `json:"defaultingType,omitempty"`
}
Expand Down