Merge pull request #96472 from Huang-Wei/automated-cherry-pick-of-#96439-upstream-release-1.19

Automated cherry pick of #96439: Fix a bug that DefaultPreemption plugin is disabled when
This commit is contained in:
Kubernetes Prow Robot 2020-11-17 05:34:22 -08:00 committed by GitHub
commit dd8776f644
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 8 deletions

View file

@ -351,6 +351,7 @@ profiles:
{Name: "TaintToleration"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
},

View file

@ -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",
@ -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",

View file

@ -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.
@ -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.
@ -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},
@ -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},
@ -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},
@ -324,6 +329,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -400,6 +406,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -487,6 +494,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -585,6 +593,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -686,6 +695,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -792,6 +802,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -910,6 +921,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -1031,6 +1043,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -1152,6 +1165,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},
@ -1277,6 +1291,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "SelectorSpread"},

View file

@ -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"
@ -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}},
},

View file

@ -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"
@ -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 != "" {

View file

@ -91,6 +91,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "NodeResourcesFit"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"ScorePlugin": {
{Name: "ImageLocality", Weight: 1},
},
@ -128,6 +129,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
@ -163,7 +165,8 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"BindPlugin": {{Name: "DefaultBinder"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
{
@ -185,6 +188,7 @@ priorities:
{Name: "NodeResourcesFit"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"ScorePlugin": {
{Name: "ImageLocality", Weight: 1},
},
@ -221,6 +225,7 @@ kind: Policy
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
@ -255,7 +260,8 @@ priorities: []
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"BindPlugin": {{Name: "DefaultBinder"}},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
} {