refactor scheduler extender related API

- move extender related API from pkg/scheduler/api to pkg/scheduler/apis/extender/v1

- alias extenderv1 to pkg/scheduler/apis/extender/v1

- use NodeScore and NodeScoreList in non-extender logic
This commit is contained in:
Wei Huang
2019-09-27 11:23:29 -07:00
parent 2ebcd2509c
commit cbdb4e3fdb
46 changed files with 703 additions and 1390 deletions

View File

@@ -23,6 +23,7 @@ import (
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
)
@@ -53,7 +54,7 @@ func TestTaintAndToleration(t *testing.T) {
tests := []struct {
pod *v1.Pod
nodes []*v1.Node
expectedList schedulerapi.HostPriorityList
expectedList framework.NodeScoreList
name string
}{
// basic test case
@@ -77,9 +78,9 @@ func TestTaintAndToleration(t *testing.T) {
Effect: v1.TaintEffectPreferNoSchedule,
}}),
},
expectedList: []schedulerapi.HostPriority{
{Host: "nodeA", Score: schedulerapi.MaxPriority},
{Host: "nodeB", Score: 0},
expectedList: []framework.NodeScore{
{Name: "nodeA", Score: schedulerapi.MaxPriority},
{Name: "nodeB", Score: 0},
},
},
// the count of taints that are tolerated by pod, does not matter.
@@ -119,10 +120,10 @@ func TestTaintAndToleration(t *testing.T) {
},
}),
},
expectedList: []schedulerapi.HostPriority{
{Host: "nodeA", Score: schedulerapi.MaxPriority},
{Host: "nodeB", Score: schedulerapi.MaxPriority},
{Host: "nodeC", Score: schedulerapi.MaxPriority},
expectedList: []framework.NodeScore{
{Name: "nodeA", Score: schedulerapi.MaxPriority},
{Name: "nodeB", Score: schedulerapi.MaxPriority},
{Name: "nodeC", Score: schedulerapi.MaxPriority},
},
},
// the count of taints on a node that are not tolerated by pod, matters.
@@ -155,10 +156,10 @@ func TestTaintAndToleration(t *testing.T) {
},
}),
},
expectedList: []schedulerapi.HostPriority{
{Host: "nodeA", Score: schedulerapi.MaxPriority},
{Host: "nodeB", Score: 5},
{Host: "nodeC", Score: 0},
expectedList: []framework.NodeScore{
{Name: "nodeA", Score: schedulerapi.MaxPriority},
{Name: "nodeB", Score: 5},
{Name: "nodeC", Score: 0},
},
},
// taints-tolerations priority only takes care about the taints and tolerations that have effect PreferNoSchedule
@@ -198,10 +199,10 @@ func TestTaintAndToleration(t *testing.T) {
},
}),
},
expectedList: []schedulerapi.HostPriority{
{Host: "nodeA", Score: schedulerapi.MaxPriority},
{Host: "nodeB", Score: schedulerapi.MaxPriority},
{Host: "nodeC", Score: 0},
expectedList: []framework.NodeScore{
{Name: "nodeA", Score: schedulerapi.MaxPriority},
{Name: "nodeB", Score: schedulerapi.MaxPriority},
{Name: "nodeC", Score: 0},
},
},
{
@@ -219,9 +220,9 @@ func TestTaintAndToleration(t *testing.T) {
},
}),
},
expectedList: []schedulerapi.HostPriority{
{Host: "nodeA", Score: schedulerapi.MaxPriority},
{Host: "nodeB", Score: 0},
expectedList: []framework.NodeScore{
{Name: "nodeA", Score: schedulerapi.MaxPriority},
{Name: "nodeB", Score: 0},
},
},
}