This is an automated email from the ASF dual-hosted git repository.
mani 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 40a64823 [YUNIKORN-3213] Check queue current usage while configuring
delay (#1064)
40a64823 is described below
commit 40a64823c510224ce88225586249d101cc99a250
Author: mani <[email protected]>
AuthorDate: Tue Feb 3 12:47:17 2026 +0530
[YUNIKORN-3213] Check queue current usage while configuring delay (#1064)
Closes: #1064
Signed-off-by: mani <[email protected]>
---
pkg/scheduler/objects/queue.go | 11 ++++++++++-
pkg/scheduler/objects/queue_test.go | 33 +++++++++++++++++++--------------
2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go
index 73a19060..43f15e6d 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -411,10 +411,19 @@ func (sq *Queue) setPreemptionTime(oldMaxResource
*resources.Resource, oldDelay
// if no current limit we should not preempt even if it was set
earlier, clear the start time
if resources.IsZero(sq.maxResource) {
sq.quotaPreemptionStartTime = time.Time{}
- log.Log(log.SchedQueue).Info("removed quota preemption start
time",
+ log.Log(log.SchedQueue).Info("max resource is not set, removed
quota preemption start time",
zap.String("queue", sq.QueuePath))
return
}
+
+ // usage is below max, so not required to set anything. clear the start
time if it was set earlier.
+ if
sq.maxResource.StrictlyGreaterThanOrEqualsOnlyExisting(sq.allocatedResource) {
+ sq.quotaPreemptionStartTime = time.Time{}
+ log.Log(log.SchedQueue).Info("usage is below max resource,
removed quota preemption start time",
+ zap.String("queue", sq.QueuePath))
+ return
+ }
+
// adjust the startup based on the diff between the delays if no change
if resources.Equals(oldMaxResource, sq.maxResource) {
if sq.quotaPreemptionStartTime.IsZero() {
diff --git a/pkg/scheduler/objects/queue_test.go
b/pkg/scheduler/objects/queue_test.go
index c494f2b5..dd1c1815 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -3193,31 +3193,36 @@ func TestQueue_setPreemptionTime(t *testing.T) {
name string
oldMaxResource *resources.Resource
maxRes map[string]string
+ currentUsage *resources.Resource
oldDelay time.Duration
delay time.Duration
oldStart bool
timeChange bool
}{
- {"empty", nil, map[string]string{}, 0, 0, false, false},
- {"no delays", resources.Zero, map[string]string{"test": "100"},
0, 0, false, false},
- {"max removed",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}), nil,
10, 10, false, false},
- {"max removed update",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}), nil,
0, 10, true, true},
- {"delay added",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "100"}, 0, 10, false, true},
- {"delay change set start",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "100"}, 5, 10, true, true},
- {"delay change no start",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "100"}, 5, 10, false, false},
- {"max lowered",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"}, 10, 10, false, true},
- {"max lowered 2nd",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"}, 10, 10, true, false},
- {"delay change max lowered 2nd",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"}, 5, 10, true, true},
- {"max increase",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 10}),
map[string]string{"test": "100"}, 5, 5, true, false},
- {"max increased 2nd with delay change",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "120"}, 5, 10, true, true}, {"max increased 2nd with
delay change",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "120"}, 5, 10, true, true},
- {"max lowered again",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"}, 10, 10, true, false},
- {"max lowered again 2nd",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"}, 10, 5, true, true},
+ {"empty", nil, map[string]string{}, nil, 0, 0, false, false},
+ {"no delays", resources.Zero, map[string]string{"test": "100"},
nil, 0, 0, false, false},
+ {"max removed",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}), nil,
nil, 10, 10, false, false},
+ {"max removed update",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}), nil,
nil, 0, 10, true, true},
+ {"delay added",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "100"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 0,
10, false, true},
+ {"delay change set start",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "100"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 5,
10, true, true},
+ {"delay change no start",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "100"}, nil, 5, 10, false, false},
+ {"max lowered",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 10,
10, false, true},
+ {"max lowered but usage is lesser than newer max",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 5}), 10, 10,
true, true},
+ {"max lowered 2nd",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 10,
10, true, false},
+ {"delay change max lowered 2nd",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 5,
10, true, true},
+ {"max increase",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 10}),
map[string]string{"test": "100"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 5, 5,
true, false},
+ {"max increase but usage is lesser than newer max",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 10}),
map[string]string{"test": "100"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 90}), 5, 5,
true, true},
+ {"max increased 2nd with delay change",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "120"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 5,
10, true, true},
+ {"max lowered again",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 10,
10, true, false},
+ {"max lowered again but usage is lesser than newer max",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 5}), 10, 10,
true, true},
+ {"max lowered again 2nd",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"}, nil, 10, 5, true, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
queue, err := createManagedQueue(root, "test", false,
tt.maxRes)
assert.NilError(t, err, "queue creation failed
unexpectedly")
queue.quotaPreemptionDelay = tt.delay
+ queue.allocatedResource = tt.currentUsage
if tt.oldStart {
queue.quotaPreemptionStartTime = time.Now()
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]