Skip to content

Commit 4819ee9

Browse files
committed
fix(capacity): prevent cyclic eviction by checking post-eviction allocation
Signed-off-by: guoqinwill <[email protected]>
1 parent 703a8f3 commit 4819ee9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/scheduler/plugins/capacity/capacity.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@ func (cp *capacityPlugin) OnSessionOpen(ssn *framework.Session) {
122122
exceptReclaimee := allocated.Clone().Sub(reclaimee.Resreq)
123123
// When scalar resource not specified in deserved such as "pods", we should skip it and consider it as infinity,
124124
// so the following first condition will be true and the current queue will not be reclaimed.
125-
if allocated.LessEqual(attr.deserved, api.Infinity) || !attr.guarantee.LessEqual(exceptReclaimee, api.Zero) {
125+
// Skip reclaim in two cases:
126+
// 1. Current allocated <= deserved (queue not over-quota yet)
127+
// 2. Evicting would cause allocated < deserved in any dimension (prevent cyclic eviction)
128+
if allocated.LessEqual(attr.deserved, api.Infinity) || exceptReclaimee.LessPartly(attr.deserved, api.Zero) {
126129
continue
127130
}
131+
128132
allocated.Sub(reclaimee.Resreq)
129133
victims = append(victims, reclaimee)
130134
}

0 commit comments

Comments
 (0)