Fix a bug that DefaultPreemption plugin is disabled when using scheduler policy

This commit is contained in:
Wei Huang 2020-11-10 17:46:37 -08:00
parent f102cc887e
commit 47a7c374c6
No known key found for this signature in database
GPG Key ID: BE5E9752F8B6E005
6 changed files with 38 additions and 11 deletions

View File

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

View File

@ -20,6 +20,7 @@ go_library(
"//pkg/scheduler/framework: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",

View File

@ -75,6 +75,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeAffinity"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
@ -95,6 +96,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
@ -136,6 +138,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeLabel"},
{Name: "ServiceAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {{Name: "PodTopologySpread"}},
"ScorePlugin": {
{Name: "NodeResourcesLeastAllocated", Weight: 1},
@ -191,6 +194,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeLabel"},
{Name: "ServiceAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {{Name: "PodTopologySpread"}},
"ScorePlugin": {
{Name: "NodeResourcesBalancedAllocation", Weight: 2},
@ -254,6 +258,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "AzureDiskLimits"},
{Name: "VolumeZone"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {{Name: "PodTopologySpread"}},
"ScorePlugin": {
{Name: "NodeResourcesBalancedAllocation", Weight: 2},
@ -324,6 +329,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -400,6 +406,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -487,6 +494,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -585,6 +593,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -686,6 +695,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -792,6 +802,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -910,6 +921,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -1031,6 +1043,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -1152,6 +1165,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},
@ -1277,6 +1291,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "VolumeZone"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "InterPodAffinity"},
{Name: "PodTopologySpread"},

View File

@ -39,6 +39,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/framework"
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"
@ -262,12 +263,15 @@ func (c *Configurator) createFromConfig(policy schedulerapi.Policy) (*Scheduler,
// Combine all framework configurations. If this results in any duplication, framework
// instantiation should fail.
// "PrioritySort" and "DefaultBinder" were neither predicates nor priorities
// "PrioritySort", "DefaultPreemption" and "DefaultBinder" were neither predicates nor priorities
// before. We add them by default.
plugins := 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

@ -140,7 +140,7 @@ func TestCreateFromConfig(t *testing.T) {
{Name: "InterPodAffinity"},
},
},
PostFilter: &schedulerapi.PluginSet{},
PostFilter: &schedulerapi.PluginSet{Enabled: []schedulerapi.Plugin{{Name: "DefaultPreemption"}}},
PreScore: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: "PodTopologySpread"},
@ -238,7 +238,7 @@ func TestCreateFromConfig(t *testing.T) {
{Name: "ServiceAffinity"},
},
},
PostFilter: &schedulerapi.PluginSet{},
PostFilter: &schedulerapi.PluginSet{Enabled: []schedulerapi.Plugin{{Name: "DefaultPreemption"}}},
PreScore: &schedulerapi.PluginSet{Enabled: []schedulerapi.Plugin{{Name: "InterPodAffinity"}}},
Score: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
@ -313,7 +313,7 @@ func TestCreateFromConfig(t *testing.T) {
{Name: "ServiceAffinity"},
},
},
PostFilter: &schedulerapi.PluginSet{},
PostFilter: &schedulerapi.PluginSet{Enabled: []schedulerapi.Plugin{{Name: "DefaultPreemption"}}},
PreScore: &schedulerapi.PluginSet{Enabled: []schedulerapi.Plugin{{Name: "InterPodAffinity"}}},
Score: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{

View File

@ -90,6 +90,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "NodeResourcesFit"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"ScorePlugin": {
{Name: "ImageLocality", Weight: 1},
},
@ -127,6 +128,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
@ -160,6 +162,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},
@ -182,6 +185,7 @@ priorities:
{Name: "NodeResourcesFit"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"ScorePlugin": {
{Name: "ImageLocality", Weight: 1},
},
@ -218,6 +222,7 @@ kind: Policy
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"PreScorePlugin": {
{Name: "PodTopologySpread"},
{Name: "InterPodAffinity"},
@ -250,6 +255,7 @@ priorities: []
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
},
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
"BindPlugin": {{Name: "DefaultBinder"}},
},
},