Skip to content

Commit 6bad36f

Browse files
authored
Merge pull request kubernetes#2895 from bskiba/extensible-prio-new
Pod Priority comparison function
2 parents 0ace054 + a28bc40 commit 6bad36f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

vertical-pod-autoscaler/pkg/updater/priority/update_priority_calculator.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,19 @@ func (list byPriority) Swap(i, j int) {
208208

209209
// Less implements reverse ordering by priority (highest priority first).
210210
func (list byPriority) Less(i, j int) bool {
211+
return list[i].priority.Less(list[j].priority)
212+
}
213+
214+
// Less compares pod update priorities.
215+
func (p PodPriority) Less(other PodPriority) bool {
211216
// 1. If any container wants to grow, the pod takes precedence.
212217
// TODO: A better policy would be to prioritize scaling down when
213218
// (a) the pod is pending
214219
// (b) there is general resource shortage
215220
// and prioritize scaling up otherwise.
216-
if list[i].priority.ScaleUp != list[j].priority.ScaleUp {
217-
return list[i].priority.ScaleUp
221+
if p.ScaleUp != other.ScaleUp {
222+
return p.ScaleUp
218223
}
219224
// 2. A pod with larger value of resourceDiff takes precedence.
220-
return list[i].priority.ResourceDiff > list[j].priority.ResourceDiff
225+
return p.ResourceDiff > other.ResourceDiff
221226
}

0 commit comments

Comments
 (0)