Skip to content

Commit

Permalink
Merge pull request #83662 from wgliang/scheduler-v2/pod-fits-host
Browse files Browse the repository at this point in the history
[migration phase 1] PodFitsHost as filter plugin
  • Loading branch information
k8s-ci-robot committed Oct 11, 2019
2 parents 017842d + b916733 commit afa394b
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 32 deletions.
93 changes: 61 additions & 32 deletions pkg/scheduler/api/compatibility/compatibility_test.go
Expand Up @@ -109,7 +109,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"PodFitsHostPorts",
"PodFitsResources",
"NoDiskConflict",
"HostName",
"TestServiceAffinity",
"TestLabelsPresence",
),
Expand All @@ -121,6 +120,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"TestServiceAntiAffinity",
"TestLabelPreference",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {
{Name: "NodeName"},
},
},
},

// Do not change this JSON after the corresponding release has been tagged.
Expand Down Expand Up @@ -156,7 +160,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"MaxEBSVolumeCount",
Expand All @@ -175,6 +178,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"TestServiceAntiAffinity",
"TestLabelPreference",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {
{Name: "NodeName"},
},
},
},

// Do not change this JSON after the corresponding release has been tagged.
Expand Down Expand Up @@ -214,7 +222,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand All @@ -236,8 +243,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"InterPodAffinityPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
},

Expand Down Expand Up @@ -281,7 +291,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand All @@ -306,8 +315,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MostRequestedPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
},
// Do not change this JSON after the corresponding release has been tagged.
Expand Down Expand Up @@ -360,7 +372,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand All @@ -385,8 +396,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MostRequestedPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand Down Expand Up @@ -451,7 +465,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand All @@ -477,8 +490,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MostRequestedPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand Down Expand Up @@ -544,7 +560,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand All @@ -571,8 +586,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MostRequestedPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand Down Expand Up @@ -642,7 +660,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand Down Expand Up @@ -670,8 +687,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MostRequestedPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand Down Expand Up @@ -753,7 +773,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand Down Expand Up @@ -782,8 +801,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"RequestedToCapacityRatioPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand Down Expand Up @@ -866,7 +888,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand Down Expand Up @@ -896,8 +917,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"RequestedToCapacityRatioPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand Down Expand Up @@ -979,7 +1003,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand Down Expand Up @@ -1010,8 +1033,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"RequestedToCapacityRatioPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand Down Expand Up @@ -1097,7 +1123,6 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"MatchNodeSelector",
"PodFitsResources",
"PodFitsHostPorts",
"HostName",
"NoDiskConflict",
"NoVolumeZoneConflict",
"CheckNodeMemoryPressure",
Expand Down Expand Up @@ -1128,8 +1153,11 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"RequestedToCapacityRatioPriority",
),
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
"FilterPlugin": {
{Name: "NodeName"},
{Name: "TaintToleration"},
},
"ScorePlugin": {{Name: "TaintToleration", Weight: 2}},
},
wantExtenders: []schedulerapi.ExtenderConfig{{
URLPrefix: "/prefix",
Expand All @@ -1153,6 +1181,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
mandatoryPredicates := sets.NewString("CheckNodeCondition")
filterToPredicateMap := map[string]string{
"TaintToleration": "PodToleratesNodeTaints",
"NodeName": "HostName",
}
scoreToPriorityMap := map[string]string{
"TaintToleration": "TaintTolerationPriority",
Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/framework/plugins/BUILD
Expand Up @@ -10,6 +10,7 @@ go_library(
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithm/priorities:go_default_library",
"//pkg/scheduler/apis/config:go_default_library",
"//pkg/scheduler/framework/plugins/nodename:go_default_library",
"//pkg/scheduler/framework/plugins/tainttoleration:go_default_library",
"//pkg/scheduler/framework/v1alpha1:go_default_library",
"//pkg/scheduler/internal/cache:go_default_library",
Expand All @@ -32,6 +33,7 @@ filegroup(
":package-srcs",
"//pkg/scheduler/framework/plugins/examples:all-srcs",
"//pkg/scheduler/framework/plugins/migration:all-srcs",
"//pkg/scheduler/framework/plugins/nodename:all-srcs",
"//pkg/scheduler/framework/plugins/tainttoleration:all-srcs",
],
tags = ["automanaged"],
Expand Down
7 changes: 7 additions & 0 deletions pkg/scheduler/framework/plugins/default_registry.go
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
"k8s.io/kubernetes/pkg/scheduler/apis/config"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodename"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/tainttoleration"
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
Expand All @@ -51,6 +52,7 @@ type RegistryArgs struct {
func NewDefaultRegistry(args *RegistryArgs) framework.Registry {
return framework.Registry{
tainttoleration.Name: tainttoleration.New,
nodename.Name: nodename.New,
}
}

Expand Down Expand Up @@ -83,6 +85,11 @@ func NewDefaultConfigProducerRegistry() *ConfigProducerRegistry {
plugins.Filter = appendToPluginSet(plugins.Filter, tainttoleration.Name, nil)
return
})
registry.RegisterPredicate(predicates.HostNamePred,
func(_ ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
plugins.Filter = appendToPluginSet(plugins.Filter, nodename.Name, nil)
return
})

registry.RegisterPriority(priorities.TaintTolerationPriority,
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
Expand Down
43 changes: 43 additions & 0 deletions pkg/scheduler/framework/plugins/nodename/BUILD
@@ -0,0 +1,43 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = ["node_name.go"],
importpath = "k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodename",
visibility = ["//visibility:public"],
deps = [
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/framework/plugins/migration:go_default_library",
"//pkg/scheduler/framework/v1alpha1:go_default_library",
"//pkg/scheduler/nodeinfo:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["node_name_test.go"],
embed = [":go_default_library"],
deps = [
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/framework/v1alpha1:go_default_library",
"//pkg/scheduler/nodeinfo:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)

0 comments on commit afa394b

Please sign in to comment.