Skip to content

Commit

Permalink
[YUNIKORN-3003] Don't consider alreadyy preempted allocations for pre…
Browse files Browse the repository at this point in the history
…emption (#1006)

Closes: #1006

Signed-off-by: Craig Condit <[email protected]>
  • Loading branch information
psantacl authored and craigcondit committed Dec 19, 2024
1 parent 149820f commit 4d50a5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/scheduler/objects/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,11 @@ func (sq *Queue) findEligiblePreemptionVictims(results map[string]*QueuePreempti
continue
}

// skip allocs which have already been preempted
if alloc.IsPreempted() {
continue
}

// if we have encountered a fence then all tasks are eligible for preemption
// otherwise the task is a candidate if its priority is less than or equal to the ask priority
if fenced || int64(alloc.GetPriority()) <= askPriority {
Expand Down
13 changes: 12 additions & 1 deletion pkg/scheduler/objects/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,8 @@ func TestFindEligiblePreemptionVictims(t *testing.T) {

// verify no victims when no allocations exist
snapshot := leaf1.FindEligiblePreemptionVictims(leaf1.QueuePath, ask)
assert.Equal(t, 5, len(snapshot), "wrong snapshot count") // leaf1, parent1, root

assert.Equal(t, 5, len(snapshot), "wrong snapshot count") // root, root.parent1, root.parent1.leaf1, root.parent2, root.parent2.leaf2
assert.Equal(t, 0, len(victims(snapshot)), "found victims")

// add two lower-priority allocs in leaf2
Expand Down Expand Up @@ -1974,6 +1975,16 @@ func TestFindEligiblePreemptionVictims(t *testing.T) {
assert.Equal(t, alloc3.allocationKey, victims(snapshot)[0].allocationKey, "wrong alloc")
alloc2.released = false

// alloc2 has already been preempted and should not be considered a valid victim
alloc2.MarkPreempted()
snapshot = leaf1.FindEligiblePreemptionVictims(leaf1.QueuePath, ask)
assert.Equal(t, 1, len(victims(snapshot)), "wrong victim count")
assert.Equal(t, alloc3.allocationKey, victims(snapshot)[0].allocationKey, "wrong alloc")
// recreate alloc2 to restore non-prempted state
app2.RemoveAllocation(alloc2.GetAllocationKey(), si.TerminationType_STOPPED_BY_RM)
alloc2 = createAllocation("ask2", appID2, nodeID1, true, true, -1000, res)
app2.AddAllocation(alloc2)

// setting priority offset on parent2 queue should remove leaf2 victims
parent2.priorityOffset = 1001
snapshot = leaf1.FindEligiblePreemptionVictims(leaf1.QueuePath, ask)
Expand Down

0 comments on commit 4d50a5a

Please sign in to comment.