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

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


The following commit(s) were added to refs/heads/branch-1.6 by this push:
     new 8c9247a5 [YUNIKORN-3003] Don't consider already preempted allocations 
for preemption (#1006)
8c9247a5 is described below

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

    [YUNIKORN-3003] Don't consider already 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 7e21bc8f..91256f3b 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -1870,6 +1870,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 2bd54b02..75aae217 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -1852,7 +1852,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
@@ -1940,6 +1941,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