mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-02 01:39:02 +00:00
Implemented taints and tolerations priority function as a Score plugin
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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}},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user