Implemented taints and tolerations priority function as a Score plugin

This commit is contained in:
Abdullah Gharaibeh
2019-10-05 20:31:51 -04:00
parent 46dd075bab
commit 7429b0fe86
17 changed files with 510 additions and 88 deletions

View File

@@ -148,17 +148,17 @@ func (sp *ScorePlugin) reset() {
}
// Score returns the score of scheduling a pod on a specific node.
func (sp *ScorePlugin) Score(state *framework.CycleState, p *v1.Pod, nodeName string) (int, *framework.Status) {
func (sp *ScorePlugin) Score(state *framework.CycleState, p *v1.Pod, nodeName string) (int64, *framework.Status) {
sp.numScoreCalled++
if sp.failScore {
return 0, framework.NewStatus(framework.Error, fmt.Sprintf("injecting failure for pod %v", p.Name))
}
score := 1
score := int64(1)
if sp.numScoreCalled == 1 {
// The first node is scored the highest, the rest is scored lower.
sp.highScoreNode = nodeName
score = int(framework.MaxNodeScore)
score = framework.MaxNodeScore
}
return score, nil
}
@@ -179,9 +179,9 @@ func (sp *ScoreWithNormalizePlugin) reset() {
}
// Score returns the score of scheduling a pod on a specific node.
func (sp *ScoreWithNormalizePlugin) Score(state *framework.CycleState, p *v1.Pod, nodeName string) (int, *framework.Status) {
func (sp *ScoreWithNormalizePlugin) Score(state *framework.CycleState, p *v1.Pod, nodeName string) (int64, *framework.Status) {
sp.numScoreCalled++
score := 10
score := int64(10)
return score, nil
}

View File

@@ -95,7 +95,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
policy string
expectedPredicates sets.String
expectedPrioritizers sets.String
expectedPlugins map[string][]string
expectedPlugins map[string][]kubeschedulerconfig.Plugin
}{
{
policy: `{
@@ -147,11 +147,11 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
"NodeAffinityPriority",
"NodePreferAvoidPodsPriority",
"SelectorSpreadPriority",
"TaintTolerationPriority",
"ImageLocalityPriority",
),
expectedPlugins: map[string][]string{
"FilterPlugin": {"TaintToleration"},
expectedPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 1}},
},
},
{
@@ -214,11 +214,11 @@ kind: Policy
"NodeAffinityPriority",
"NodePreferAvoidPodsPriority",
"SelectorSpreadPriority",
"TaintTolerationPriority",
"ImageLocalityPriority",
),
expectedPlugins: map[string][]string{
"FilterPlugin": {"TaintToleration"},
expectedPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {{Name: "TaintToleration"}},
"ScorePlugin": {{Name: "TaintToleration", Weight: 1}},
},
},
{