Skip to content

Commit ee4d601

Browse files
committed
fix(capacity): ensure allocated resources remain above deserved after evction
Signed-off-by: guoqinwill <[email protected]>
1 parent 703a8f3 commit ee4d601

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkg/scheduler/plugins/capacity/capacity.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,16 @@ func (cp *capacityPlugin) OnSessionOpen(ssn *framework.Session) {
120120
allocated := allocations[job.Queue]
121121

122122
exceptReclaimee := allocated.Clone().Sub(reclaimee.Resreq)
123-
// When scalar resource not specified in deserved such as "pods", we should skip it and consider it as infinity,
124-
// 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) {
123+
// The `api.Infinity` parameter ensures that for any scalar resource present in `allocated` but not defined in `deserved` (e.g., "pods"),
124+
// the check is skipped, effectively treating `deserved` as infinite for that resource. This prevents such resources from causing a reclaim.
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 reclaimer's requested dimension
128+
reclaimable, _ := attr.deserved.LessEqualWithDimensionAndResourcesName(exceptReclaimee, reclaimer.Resreq)
129+
if allocated.LessEqual(attr.deserved, api.Infinity) || !reclaimable {
126130
continue
127131
}
132+
128133
allocated.Sub(reclaimee.Resreq)
129134
victims = append(victims, reclaimee)
130135
}

0 commit comments

Comments
 (0)