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

Fix integration test flake on TestScorePlugin #93493

Merged
merged 1 commit into from Jul 28, 2020
Merged
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
7 changes: 4 additions & 3 deletions test/integration/scheduler/framework_test.go
Expand Up @@ -19,6 +19,7 @@ package scheduler
import (
"context"
"fmt"
"sync/atomic"
"testing"
"time"

Expand All @@ -45,7 +46,7 @@ type PreFilterPlugin struct {

type ScorePlugin struct {
failScore bool
numScoreCalled int
numScoreCalled int32
highScoreNode string
}

Expand Down Expand Up @@ -170,13 +171,13 @@ func (sp *ScorePlugin) reset() {

// Score returns the score of scheduling a pod on a specific node.
func (sp *ScorePlugin) Score(ctx context.Context, state *framework.CycleState, p *v1.Pod, nodeName string) (int64, *framework.Status) {
sp.numScoreCalled++
curCalled := atomic.AddInt32(&sp.numScoreCalled, 1)
if sp.failScore {
return 0, framework.NewStatus(framework.Error, fmt.Sprintf("injecting failure for pod %v", p.Name))
}

score := int64(1)
if sp.numScoreCalled == 1 {
if curCalled == 1 {
// The first node is scored the highest, the rest is scored lower.
sp.highScoreNode = nodeName
score = framework.MaxNodeScore
Expand Down