Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-3003] Don't consider already preempted allocations for preemption #1006

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading