Skip to content

Commit b4ad2e0

Browse files
mayabarvMaroon
authored andcommitted
Support negative score weights
1 parent c5749c7 commit b4ad2e0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pkg/epp/scheduling/scorer.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,21 @@ func (sm *ScorerMng) scoreTargets(ctx *types.Context, pods []*types.PodMetrics)
7373

7474
// select pod with maximum score, if more than one with the max score - use random pods from the list
7575
var highestScoreTargets []*types.PodMetrics
76-
maxScore := -1.0
76+
// score weights cound be negative
77+
maxScore := 0.0
78+
isFirst := true
7779

7880
for pod, score := range podsTotalScore {
79-
if score > maxScore {
81+
if isFirst {
8082
maxScore = score
8183
highestScoreTargets = []*types.PodMetrics{pod}
82-
} else if score == maxScore {
83-
highestScoreTargets = append(highestScoreTargets, pod)
84+
} else {
85+
if score > maxScore {
86+
maxScore = score
87+
highestScoreTargets = []*types.PodMetrics{pod}
88+
} else if score == maxScore {
89+
highestScoreTargets = append(highestScoreTargets, pod)
90+
}
8491
}
8592
}
8693

0 commit comments

Comments
 (0)