Skip to content

Commit 0ea66e6

Browse files
authored
Add min-runtime configuration to queues (#155)
* add min-runtime configuration to queues * update CHANGELOG
1 parent d344404 commit 0ea66e6

File tree

6 files changed

+61
-4
lines changed

6 files changed

+61
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
99
### Added
1010
- Added support for [k8s pod scheduling gates](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-scheduling-readiness/)
1111
- nodeSelector, affinity and tolerations configurable with global value definitions
12+
- Added `PreemptMinRuntime` and `ReclaimMinRuntime` properties to queue CRD
1213
- Scheduler now adds a "LastStartTimestamp" to podgroup on allocation
1314

1415
### Changed

deployments/kai-scheduler/crds/scheduling.run.ai_queues.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,17 @@ spec:
5858
type: string
5959
parentQueue:
6060
type: string
61+
preemptMinRuntime:
62+
description: Minimum runtime of a job in queue before it can be preempted.
63+
type: string
6164
priority:
6265
description: |-
6366
Priority of the queue. Over-quota resources will be divided first among queues with higher priority. Queues with
6467
higher priority will be considerd first for allocation, and last for reclaim. When not set, default is 100.
6568
type: integer
69+
reclaimMinRuntime:
70+
description: Minimum runtime of a job in queue before it can be reclaimed.
71+
type: string
6672
resources:
6773
properties:
6874
cpu:

pkg/apis/scheduling/v2/queue_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ type QueueSpec struct {
2020
// higher priority will be considerd first for allocation, and last for reclaim. When not set, default is 100.
2121
// +optional
2222
Priority *int `json:"priority,omitempty"`
23+
24+
// Minimum runtime of a job in queue before it can be preempted.
25+
// +optional
26+
PreemptMinRuntime *metav1.Duration `json:"preemptMinRuntime,omitempty"`
27+
28+
// Minimum runtime of a job in queue before it can be reclaimed.
29+
// +optional
30+
ReclaimMinRuntime *metav1.Duration `json:"reclaimMinRuntime,omitempty"`
2331
}
2432

2533
// QueueStatus defines the observed state of Queue

pkg/apis/scheduling/v2/zz_generated.deepcopy.go

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/scheduler/api/queue_info/queue_info.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type QueueInfo struct {
2121
Resources QueueQuota
2222
Priority int
2323
CreationTimestamp metav1.Time
24+
PreemptMinRuntime *metav1.Duration
25+
ReclaimMinRuntime *metav1.Duration
2426
}
2527

2628
func NewQueueInfo(queue *enginev2.Queue) *QueueInfo {
@@ -42,6 +44,8 @@ func NewQueueInfo(queue *enginev2.Queue) *QueueInfo {
4244
Resources: getQueueQuota(*queue),
4345
Priority: priority,
4446
CreationTimestamp: queue.CreationTimestamp,
47+
PreemptMinRuntime: queue.Spec.PreemptMinRuntime,
48+
ReclaimMinRuntime: queue.Spec.ReclaimMinRuntime,
4549
}
4650
}
4751

pkg/scheduler/api/queue_info/queue_info_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package queue_info
55

66
import (
77
"testing"
8+
"time"
89

910
"gotest.tools/assert"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -89,6 +90,32 @@ func TestNewQueueInfo(t *testing.T) {
8990
CreationTimestamp: metav1.Time{},
9091
},
9192
},
93+
{
94+
name: "queue with min-runtime",
95+
queue: &enginev2.Queue{
96+
ObjectMeta: metav1.ObjectMeta{
97+
Name: "queue",
98+
},
99+
Spec: enginev2.QueueSpec{
100+
DisplayName: "",
101+
ParentQueue: "",
102+
Resources: nil,
103+
PreemptMinRuntime: &metav1.Duration{Duration: 10 * time.Minute},
104+
ReclaimMinRuntime: &metav1.Duration{Duration: 10 * time.Minute},
105+
},
106+
},
107+
expected: QueueInfo{
108+
UID: "queue",
109+
Name: "queue",
110+
ParentQueue: "",
111+
ChildQueues: []common_info.QueueID{},
112+
Resources: QueueQuota{},
113+
Priority: 100,
114+
CreationTimestamp: metav1.Time{},
115+
PreemptMinRuntime: &metav1.Duration{Duration: 10 * time.Minute},
116+
ReclaimMinRuntime: &metav1.Duration{Duration: 10 * time.Minute},
117+
},
118+
},
92119
{
93120
name: "queue with parent",
94121
queue: &enginev2.Queue{

0 commit comments

Comments
 (0)