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

Automated cherry pick of #96439: Fix a bug that DefaultPreemption plugin is disabled when #96472

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
1 change: 1 addition & 0 deletions cmd/kube-scheduler/app/server_test.go
Expand Up @@ -351,6 +351,7 @@ profiles:
{Name: "TaintToleration"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/BUILD
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/scheduler/core:go_default_library",
"//pkg/scheduler/framework/plugins:go_default_library",
"//pkg/scheduler/framework/plugins/defaultbinder:go_default_library",
"//pkg/scheduler/framework/plugins/defaultpreemption:go_default_library",
"//pkg/scheduler/framework/plugins/noderesources:go_default_library",
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
"//pkg/scheduler/framework/runtime:go_default_library",
Expand Down Expand Up @@ -65,6 +66,7 @@ go_test(
"//pkg/scheduler/core:go_default_library",
"//pkg/scheduler/framework/plugins:go_default_library",
"//pkg/scheduler/framework/plugins/defaultbinder:go_default_library",
"//pkg/scheduler/framework/plugins/defaultpreemption:go_default_library",
"//pkg/scheduler/framework/plugins/interpodaffinity:go_default_library",
"//pkg/scheduler/framework/plugins/nodelabel:go_default_library",
"//pkg/scheduler/framework/plugins/nodeports:go_default_library",
Expand Down
25 changes: 20 additions & 5 deletions pkg/scheduler/apis/config/testing/compatibility_test.go
Expand Up @@ -75,7 +75,8 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeAffinity"},
{Name: "TaintToleration"},
},
"BindPlugin": {{Name: "DefaultBinder"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
// This is a special test for the case where a policy is specified without specifying any filters.
Expand All @@ -95,7 +96,8 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"BindPlugin": {{Name: "DefaultBinder"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
// Do not change this JSON after the corresponding release has been tagged.
Expand Down Expand Up @@ -136,7 +138,8 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeLabel"},
{Name: "ServiceAffinity"},
},
"PreScorePlugin": {{Name: "SelectorSpread"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {{Name: "SelectorSpread"}},
"ScorePlugin": {
{Name: "NodeResourcesLeastAllocated", Weight: 1},
{Name: "NodeLabel", Weight: 4},
Expand Down Expand Up @@ -191,7 +194,8 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeLabel"},
{Name: "ServiceAffinity"},
},
"PreScorePlugin": {{Name: "SelectorSpread"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {{Name: "SelectorSpread"}},
"ScorePlugin": {
{Name: "NodeResourcesBalancedAllocation", Weight: 2},
{Name: "NodeResourcesLeastAllocated", Weight: 2},
Expand Down Expand Up @@ -254,7 +258,8 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "AzureDiskLimits"},
{Name: "VolumeZone"},
},
"PreScorePlugin": {{Name: "SelectorSpread"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {{Name: "SelectorSpread"}},
"ScorePlugin": {
{Name: "NodeResourcesBalancedAllocation", Weight: 2},
{Name: "ImageLocality", Weight: 2},
Expand Down Expand Up @@ -324,6 +329,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -400,6 +406,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -487,6 +494,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -585,6 +593,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -686,6 +695,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -792,6 +802,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -910,6 +921,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -1031,6 +1043,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -1152,6 +1165,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down Expand Up @@ -1277,6 +1291,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
Expand Down
6 changes: 5 additions & 1 deletion pkg/scheduler/factory.go
Expand Up @@ -42,6 +42,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/core"
frameworkplugins "k8s.io/kubernetes/pkg/scheduler/framework/plugins"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultbinder"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/noderesources"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
frameworkruntime "k8s.io/kubernetes/pkg/scheduler/framework/runtime"
Expand Down Expand Up @@ -290,12 +291,15 @@ func (c *Configurator) createFromConfig(policy schedulerapi.Policy) (*Scheduler,
// Combine all framework configurations. If this results in any duplication, framework
// instantiation should fail.
var defPlugins schedulerapi.Plugins
// "PrioritySort" and "DefaultBinder" were neither predicates nor priorities
// "PrioritySort", "DefaultPreemption" and "DefaultBinder" were neither predicates nor priorities
// before. We add them by default.
defPlugins.Append(&schedulerapi.Plugins{
QueueSort: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{{Name: queuesort.Name}},
},
PostFilter: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{{Name: defaultpreemption.Name}},
},
Bind: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{{Name: defaultbinder.Name}},
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/scheduler/factory_test.go
Expand Up @@ -40,6 +40,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"
frameworkplugins "k8s.io/kubernetes/pkg/scheduler/framework/plugins"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultbinder"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/interpodaffinity"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodelabel"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
Expand Down Expand Up @@ -113,6 +114,11 @@ func TestCreateFromConfig(t *testing.T) {
if diff := cmp.Diff(wantQueuePls, queueSortPls); diff != "" {
t.Errorf("Unexpected QueueSort plugins (-want, +got): %s", diff)
}
postFilterPls := prof.ListPlugins()["PostFilterPlugin"]
wantPostFilterPls := []schedulerapi.Plugin{{Name: defaultpreemption.Name}}
if diff := cmp.Diff(wantPostFilterPls, postFilterPls); diff != "" {
t.Errorf("Unexpected PostFilter plugins (-want, +got): %s", diff)
}
bindPls := prof.ListPlugins()["BindPlugin"]
wantBindPls := []schedulerapi.Plugin{{Name: defaultbinder.Name}}
if diff := cmp.Diff(wantBindPls, bindPls); diff != "" {
Expand Down
10 changes: 8 additions & 2 deletions test/integration/scheduler/scheduler_test.go
Expand Up @@ -91,6 +91,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "NodeResourcesFit"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"ScorePlugin": {
{Name: "ImageLocality", Weight: 1},
},
Expand Down Expand Up @@ -128,6 +129,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
Expand Down Expand Up @@ -163,7 +165,8 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"BindPlugin": {{Name: "DefaultBinder"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
{
Expand All @@ -185,6 +188,7 @@ priorities:
{Name: "NodeResourcesFit"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"ScorePlugin": {
{Name: "ImageLocality", Weight: 1},
},
Expand Down Expand Up @@ -221,6 +225,7 @@ kind: Policy
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
Expand Down Expand Up @@ -255,7 +260,8 @@ priorities: []
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"BindPlugin": {{Name: "DefaultBinder"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
} {
Expand Down