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

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


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new 2d0abdae ADDENDUM [YUNIKORN-2772] Scheduler restart does not preserve 
app start time (#1019)
2d0abdae is described below

commit 2d0abdae1e7bdea5b88ade6963cb4ee802ce6c5f
Author: Peter Bacsko <[email protected]>
AuthorDate: Tue Jun 10 20:56:04 2025 +0200

    ADDENDUM [YUNIKORN-2772] Scheduler restart does not preserve app start time 
(#1019)
    
    Closes: #1019
    
    Signed-off-by: Peter Bacsko <[email protected]>
    (cherry picked from commit d5edb7abdf65149845d1fb41b12f388003cdfa4e)
---
 pkg/scheduler/objects/application.go      |  3 +++
 pkg/scheduler/objects/application_test.go | 12 +++++++++
 pkg/scheduler/partition_test.go           | 42 +++++++++++++++++++++++++------
 pkg/scheduler/utilities_test.go           |  5 ++++
 4 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/pkg/scheduler/objects/application.go 
b/pkg/scheduler/objects/application.go
index 9eb0e3ed..c9e15a41 100644
--- a/pkg/scheduler/objects/application.go
+++ b/pkg/scheduler/objects/application.go
@@ -1723,6 +1723,9 @@ func (sa *Application) addAllocationInternal(allocType 
AllocationResultType, all
                sa.allocatedResource = resources.Add(sa.allocatedResource, 
alloc.GetAllocatedResource())
                sa.maxAllocatedResource = 
resources.ComponentWiseMax(sa.allocatedResource, sa.maxAllocatedResource)
        }
+       if alloc.createTime.Before(sa.submissionTime) {
+               sa.submissionTime = alloc.createTime
+       }
        sa.appEvents.SendNewAllocationEvent(sa.ApplicationID, 
alloc.allocationKey, alloc.GetAllocatedResource())
        sa.allocations[alloc.GetAllocationKey()] = alloc
 }
diff --git a/pkg/scheduler/objects/application_test.go 
b/pkg/scheduler/objects/application_test.go
index 2c110330..cf79b3a6 100644
--- a/pkg/scheduler/objects/application_test.go
+++ b/pkg/scheduler/objects/application_test.go
@@ -3657,6 +3657,7 @@ func TestAppSubmissionTime(t *testing.T) {
        assert.NilError(t, err, "queue create failed")
        app.queue = queue
 
+       // asks
        res := 
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 5})
        ask1 := newAllocationAsk(aKey, appID1, res)
        ask1.createTime = time.Unix(0, 100)
@@ -3672,4 +3673,15 @@ func TestAppSubmissionTime(t *testing.T) {
        err = app.AddAllocationAsk(ask3)
        assert.NilError(t, err)
        assert.Equal(t, app.submissionTime, time.Unix(0, 50), "app submission 
time is not set properly")
+
+       // allocations
+       alloc1 := newAllocation(appID1, nodeID1, res)
+       alloc1.createTime = time.Unix(0, 60)
+       app.AddAllocation(alloc1)
+       assert.Equal(t, app.submissionTime, time.Unix(0, 50), "app submission 
time is not set properly")
+
+       alloc2 := newAllocation(appID1, nodeID1, res)
+       alloc2.createTime = time.Unix(0, 30)
+       app.AddAllocation(alloc2)
+       assert.Equal(t, app.submissionTime, time.Unix(0, 30), "app submission 
time is not set properly")
 }
diff --git a/pkg/scheduler/partition_test.go b/pkg/scheduler/partition_test.go
index fb3ee7ac..a01d4599 100644
--- a/pkg/scheduler/partition_test.go
+++ b/pkg/scheduler/partition_test.go
@@ -4843,32 +4843,60 @@ func TestAppSchedulingOrderFIFO(t *testing.T) {
        // add two asks to app2 first
        app2AskRes := 
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 2})
 
-       app2Ask1 := newAllocationAskAll(allocKey2, appID2, "", app2AskRes, 0, 
false, map[string]string{
+       app2Ask1 := newAllocationAskAll("app2-alloc-1", appID2, "", app2AskRes, 
0, false, map[string]string{
                siCommon.CreationTime: "100",
        })
        err = app2.AddAllocationAsk(app2Ask1)
        assert.NilError(t, err, "could not add ask")
-       app2Ask2 := newAllocationAskAll(allocKey3, appID2, "", app2AskRes, 0, 
false, map[string]string{
+       app2Ask2 := newAllocationAskAll("app2-alloc-2", appID2, "", app2AskRes, 
0, false, map[string]string{
                siCommon.CreationTime: "50",
        })
        err = app2.AddAllocationAsk(app2Ask2)
        assert.NilError(t, err, "could not add ask")
+       app2Ask3 := newAllocationAskAll("app2-alloc-3", appID2, "", app2AskRes, 
0, false, map[string]string{
+               siCommon.CreationTime: "150",
+       })
+       err = app2.AddAllocationAsk(app2Ask3)
+       assert.NilError(t, err, "could not add ask")
 
        askRes1 := 
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 1})
-       ask1 := newAllocationAskAll(allocKey, appID1, "", askRes1, 0, false, 
map[string]string{
+       app1Ask1 := newAllocationAskAll("app1-alloc-1", appID1, "", askRes1, 0, 
false, map[string]string{
                siCommon.CreationTime: "1000",
        })
-       err = app1.AddAllocationAsk(ask1)
+       err = app1.AddAllocationAsk(app1Ask1)
+       assert.NilError(t, err, "could not add ask")
+       app1Ask2 := newAllocationAskAll("app1-alloc-2", appID1, "", askRes1, 0, 
false, map[string]string{
+               siCommon.CreationTime: "1100",
+       })
+       err = app1.AddAllocationAsk(app1Ask2)
        assert.NilError(t, err, "could not add ask")
 
        // the two asks from app2 should be scheduled
        alloc := partition.tryAllocate()
        assert.Assert(t, alloc != nil, "no allocation was made")
-       assert.Equal(t, allocKey3, alloc.Request.GetAllocationKey())
+       assert.Equal(t, "app2-alloc-2", alloc.Request.GetAllocationKey())
        alloc = partition.tryAllocate()
        assert.Assert(t, alloc != nil, "no allocation was made")
-       assert.Equal(t, allocKey2, alloc.Request.GetAllocationKey())
+       assert.Equal(t, "app2-alloc-1", alloc.Request.GetAllocationKey())
+
+       // add existing allocation to appID1 - should change scheduling order
+       allocExisting := newAllocationAllTags("allocExisting", appID1, nodeID1, 
"",
+               
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 1}), 0, 
false, map[string]string{
+                       siCommon.CreationTime: "30", // older than app2Ask2 
(alloc-3)
+               })
+       app1.AddAllocation(allocExisting)
+
+       // should schedule from app-1
+       alloc = partition.tryAllocate()
+       assert.Assert(t, alloc != nil, "no allocation was made")
+       assert.Equal(t, "app1-alloc-1", alloc.Request.GetAllocationKey())
+
+       alloc = partition.tryAllocate()
+       assert.Assert(t, alloc != nil, "no allocation was made")
+       assert.Equal(t, "app1-alloc-2", alloc.Request.GetAllocationKey())
+
+       // latest from app-2 again
        alloc = partition.tryAllocate()
        assert.Assert(t, alloc != nil, "no allocation was made")
-       assert.Equal(t, allocKey, alloc.Request.GetAllocationKey())
+       assert.Equal(t, "app2-alloc-3", alloc.Request.GetAllocationKey())
 }
diff --git a/pkg/scheduler/utilities_test.go b/pkg/scheduler/utilities_test.go
index 8e6a9af3..95ec88f0 100644
--- a/pkg/scheduler/utilities_test.go
+++ b/pkg/scheduler/utilities_test.go
@@ -590,6 +590,10 @@ func newAllocation(allocKey, appID, nodeID string, res 
*resources.Resource) *obj
 }
 
 func newAllocationAll(allocKey, appID, nodeID, taskGroup string, res 
*resources.Resource, prio int32, placeHolder bool) *objects.Allocation {
+       return newAllocationAllTags(allocKey, appID, nodeID, taskGroup, res, 
prio, placeHolder, nil)
+}
+
+func newAllocationAllTags(allocKey, appID, nodeID, taskGroup string, res 
*resources.Resource, prio int32, placeHolder bool, tags map[string]string) 
*objects.Allocation {
        return objects.NewAllocationFromSI(&si.Allocation{
                AllocationKey:    allocKey,
                ApplicationID:    appID,
@@ -599,6 +603,7 @@ func newAllocationAll(allocKey, appID, nodeID, taskGroup 
string, res *resources.
                Priority:         prio,
                TaskGroupName:    taskGroup,
                Placeholder:      placeHolder,
+               AllocationTags:   tags,
        })
 }
 


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

Reply via email to