This is an automated email from the ASF dual-hosted git repository.

ccondit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d50a5a1 [YUNIKORN-3003] Don't consider alreadyy preempted allocations 
for preemption (#1006)
4d50a5a1 is described below

commit 4d50a5a1efb03413c9c1b704f8c00f34fa8110a8
Author: Paul Santa Clara <[email protected]>
AuthorDate: Thu Dec 19 14:59:03 2024 -0600

    [YUNIKORN-3003] Don't consider alreadyy preempted allocations for 
preemption (#1006)
    
    Closes: #1006
    
    Signed-off-by: Craig Condit <[email protected]>
---
 pkg/scheduler/objects/queue.go      |  5 +++++
 pkg/scheduler/objects/queue_test.go | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go
index 507ee3d9..6394bc04 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -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 {
diff --git a/pkg/scheduler/objects/queue_test.go 
b/pkg/scheduler/objects/queue_test.go
index 3ad286b9..f2f24296 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -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
@@ -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)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to