mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
fix(scheduler): correct sorting for HostPriorityList
This commit is contained in:
@@ -116,6 +116,10 @@ func NormalLess(b1, b2 *ScoreBucket) bool {
|
||||
return b1.normalScore.Total() < b2.normalScore.Total()
|
||||
}
|
||||
|
||||
func NormalEqual(b1, b2 *ScoreBucket) bool {
|
||||
return b1.normalScore.Total() == b2.normalScore.Total()
|
||||
}
|
||||
|
||||
func (b *ScoreBucket) debugString(kind string, vals map[string]int) string {
|
||||
return fmt.Sprintf("%s: %v", kind, vals)
|
||||
}
|
||||
|
||||
@@ -159,11 +159,6 @@ func (h HostPriorityList) Less(i, j int) bool {
|
||||
s2 := h[j].Score.ScoreBucket
|
||||
preferLess := score.PreferLess(s1, s2)
|
||||
avoidLess := score.AvoidLess(s1, s2)
|
||||
normalLess := score.NormalLess(s1, s2)
|
||||
|
||||
if !(preferLess || avoidLess || normalLess) {
|
||||
return h[i].Host < h[j].Host
|
||||
}
|
||||
|
||||
if preferLess {
|
||||
return true
|
||||
@@ -171,7 +166,10 @@ func (h HostPriorityList) Less(i, j int) bool {
|
||||
if avoidLess {
|
||||
return false
|
||||
}
|
||||
return normalLess
|
||||
if score.NormalEqual(s1, s2) {
|
||||
return h[i].Host < h[j].Host
|
||||
}
|
||||
return score.NormalLess(s1, s2)
|
||||
}
|
||||
|
||||
func (h HostPriorityList) Swap(i, j int) {
|
||||
|
||||
Reference in New Issue
Block a user