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

Implement default queue sort logic as a scheduler plugin #87261

Merged
merged 1 commit into from Jan 17, 2020
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
2 changes: 2 additions & 0 deletions pkg/scheduler/BUILD
Expand Up @@ -21,6 +21,7 @@ go_library(
"//pkg/scheduler/framework/plugins:go_default_library",
"//pkg/scheduler/framework/plugins/interpodaffinity:go_default_library",
"//pkg/scheduler/framework/plugins/noderesources:go_default_library",
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
"//pkg/scheduler/framework/v1alpha1:go_default_library",
"//pkg/scheduler/internal/cache:go_default_library",
"//pkg/scheduler/internal/cache/debugger:go_default_library",
Expand Down Expand Up @@ -71,6 +72,7 @@ go_test(
"//pkg/scheduler/framework/plugins/nodelabel:go_default_library",
"//pkg/scheduler/framework/plugins/nodeports:go_default_library",
"//pkg/scheduler/framework/plugins/noderesources:go_default_library",
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
"//pkg/scheduler/framework/plugins/serviceaffinity:go_default_library",
"//pkg/scheduler/framework/plugins/volumebinding:go_default_library",
"//pkg/scheduler/framework/v1alpha1:go_default_library",
Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/algorithmprovider/BUILD
Expand Up @@ -24,6 +24,7 @@ go_library(
"//pkg/scheduler/framework/plugins/nodeunschedulable:go_default_library",
"//pkg/scheduler/framework/plugins/nodevolumelimits:go_default_library",
"//pkg/scheduler/framework/plugins/podtopologyspread:go_default_library",
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
"//pkg/scheduler/framework/plugins/tainttoleration:go_default_library",
"//pkg/scheduler/framework/plugins/volumebinding:go_default_library",
"//pkg/scheduler/framework/plugins/volumerestrictions:go_default_library",
Expand Down Expand Up @@ -52,6 +53,7 @@ go_test(
"//pkg/scheduler/framework/plugins/nodeunschedulable:go_default_library",
"//pkg/scheduler/framework/plugins/nodevolumelimits:go_default_library",
"//pkg/scheduler/framework/plugins/podtopologyspread:go_default_library",
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
"//pkg/scheduler/framework/plugins/tainttoleration:go_default_library",
"//pkg/scheduler/framework/plugins/volumebinding:go_default_library",
"//pkg/scheduler/framework/plugins/volumerestrictions:go_default_library",
Expand Down
6 changes: 6 additions & 0 deletions pkg/scheduler/algorithmprovider/registry.go
Expand Up @@ -37,6 +37,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodeunschedulable"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodevolumelimits"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/podtopologyspread"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/tainttoleration"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumerestrictions"
Expand Down Expand Up @@ -83,6 +84,11 @@ func ListAlgorithmProviders() string {
func getDefaultConfig(hardPodAffinityWeight int64) *Config {
return &Config{
FrameworkPlugins: &schedulerapi.Plugins{
QueueSort: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: queuesort.Name},
},
},
PreFilter: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: noderesources.FitName},
Expand Down
16 changes: 16 additions & 0 deletions pkg/scheduler/algorithmprovider/registry_test.go
Expand Up @@ -21,6 +21,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"

"k8s.io/apimachinery/pkg/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
Expand Down Expand Up @@ -48,6 +49,11 @@ func TestClusterAutoscalerProvider(t *testing.T) {
hardPodAffinityWeight := int64(1)
wantConfig := &Config{
FrameworkPlugins: &schedulerapi.Plugins{
QueueSort: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: queuesort.Name},
},
},
PreFilter: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: noderesources.FitName},
Expand Down Expand Up @@ -120,6 +126,11 @@ func TestApplyFeatureGates(t *testing.T) {
featuresEnabled: false,
wantConfig: &Config{
FrameworkPlugins: &schedulerapi.Plugins{
QueueSort: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: queuesort.Name},
},
},
PreFilter: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: noderesources.FitName},
Expand Down Expand Up @@ -178,6 +189,11 @@ func TestApplyFeatureGates(t *testing.T) {
featuresEnabled: true,
wantConfig: &Config{
FrameworkPlugins: &schedulerapi.Plugins{
QueueSort: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: queuesort.Name},
},
},
PreFilter: &schedulerapi.PluginSet{
Enabled: []schedulerapi.Plugin{
{Name: noderesources.FitName},
Expand Down
23 changes: 23 additions & 0 deletions pkg/scheduler/apis/config/testing/compatibility_test.go
Expand Up @@ -61,6 +61,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodeResourcesFit"},
{Name: "NodePorts"},
Expand All @@ -87,6 +88,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"FilterPlugin": {
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
Expand Down Expand Up @@ -115,6 +117,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -167,6 +170,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -224,6 +228,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -290,6 +295,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -364,6 +370,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -449,6 +456,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -545,6 +553,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -642,6 +651,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -743,6 +753,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -856,6 +867,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -971,6 +983,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -1086,6 +1099,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -1206,6 +1220,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
}]
}`,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "NodePorts"},
{Name: "NodeResourcesFit"},
Expand Down Expand Up @@ -1279,6 +1294,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
features.EvenPodsSpread: true,
},
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PreFilterPlugin": {
{Name: "PodTopologySpread"},
},
Expand Down Expand Up @@ -1309,6 +1325,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
features.ResourceLimitsPriorityFunction: true,
},
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {{Name: "PrioritySort"}},
"PostFilterPlugin": {
{Name: "NodeResourceLimits"},
},
Expand Down Expand Up @@ -1382,6 +1399,9 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
func TestAlgorithmProviderCompatibility(t *testing.T) {
// Add serialized versions of scheduler config that exercise available options to ensure compatibility between releases
defaultPlugins := map[string][]config.Plugin{
"QueueSortPlugin": {
{Name: "PrioritySort"},
},
"PreFilterPlugin": {
{Name: "NodeResourcesFit"},
{Name: "NodePorts"},
Expand Down Expand Up @@ -1438,6 +1458,9 @@ func TestAlgorithmProviderCompatibility(t *testing.T) {
name: "ClusterAutoscalerProvider",
provider: algorithmprovider.ClusterAutoscalerProvider,
wantPlugins: map[string][]config.Plugin{
"QueueSortPlugin": {
{Name: "PrioritySort"},
},
"PreFilterPlugin": {
{Name: "NodeResourcesFit"},
{Name: "NodePorts"},
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/core/BUILD
Expand Up @@ -57,6 +57,7 @@ go_test(
"//pkg/scheduler/framework/plugins/noderesources:go_default_library",
"//pkg/scheduler/framework/plugins/nodeunschedulable:go_default_library",
"//pkg/scheduler/framework/plugins/podtopologyspread:go_default_library",
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
"//pkg/scheduler/framework/plugins/tainttoleration:go_default_library",
"//pkg/scheduler/framework/plugins/volumebinding:go_default_library",
"//pkg/scheduler/framework/plugins/volumerestrictions:go_default_library",
Expand Down
15 changes: 13 additions & 2 deletions pkg/scheduler/core/extender_test.go
Expand Up @@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/algorithm"
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
extenderv1 "k8s.io/kubernetes/pkg/scheduler/apis/extender/v1"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
internalqueue "k8s.io/kubernetes/pkg/scheduler/internal/queue"
Expand Down Expand Up @@ -366,6 +367,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
{
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand All @@ -382,6 +384,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
{
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand All @@ -398,6 +401,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
{
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand All @@ -418,6 +422,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
{
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand All @@ -434,6 +439,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
{
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand All @@ -453,6 +459,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
{
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand All @@ -478,6 +485,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterScorePlugin("Machine2Prioritizer", newMachine2PrioritizerPlugin(), 20),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand Down Expand Up @@ -505,6 +513,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterScorePlugin("Machine2Prioritizer", newMachine2PrioritizerPlugin(), 1),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand All @@ -530,6 +539,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
// because of the errors from errorPredicateExtender.
registerPlugins: []st.RegisterPluginFunc{
st.RegisterFilterPlugin("TrueFilter", NewTrueFilterPlugin),
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
},
extenders: []FakeExtender{
{
Expand Down Expand Up @@ -568,8 +578,9 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {

registry := framework.Registry{}
plugins := &schedulerapi.Plugins{
Filter: &schedulerapi.PluginSet{},
Score: &schedulerapi.PluginSet{},
QueueSort: &schedulerapi.PluginSet{},
Filter: &schedulerapi.PluginSet{},
Score: &schedulerapi.PluginSet{},
}
var pluginConfigs []schedulerapi.PluginConfig
for _, f := range test.registerPlugins {
Expand Down