Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 5b1b769

Browse files
authored
Merge pull request #464 from adam-marek/amarek-ordering
Order gang scheduled jobs based on time of arrival
2 parents a3bfd56 + 461a695 commit 5b1b769

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pkg/scheduler/api/job_info.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package api
1818

1919
import (
2020
"fmt"
21-
2221
"k8s.io/api/core/v1"
2322
policyv1 "k8s.io/api/policy/v1beta1"
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
"k8s.io/apimachinery/pkg/types"
2525

2626
arbcorev1 "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1"
@@ -128,7 +128,8 @@ type JobInfo struct {
128128
Allocated *Resource
129129
TotalRequest *Resource
130130

131-
PodGroup *arbcorev1.PodGroup
131+
CreationTimestamp metav1.Time
132+
PodGroup *arbcorev1.PodGroup
132133

133134
// TODO(k82cn): keep backward compatbility, removed it when v1alpha1 finalized.
134135
PDB *policyv1.PodDisruptionBudget
@@ -164,6 +165,7 @@ func (ji *JobInfo) SetPodGroup(pg *arbcorev1.PodGroup) {
164165
ji.Queue = QueueID(pg.Spec.Queue)
165166
}
166167

168+
ji.CreationTimestamp = pg.GetCreationTimestamp()
167169
ji.PodGroup = pg
168170
}
169171

@@ -173,6 +175,7 @@ func (ji *JobInfo) SetPDB(pdb *policyv1.PodDisruptionBudget) {
173175
ji.Namespace = pdb.Namespace
174176
ji.Queue = QueueID(pdb.Namespace)
175177

178+
ji.CreationTimestamp = pdb.GetCreationTimestamp()
176179
ji.PDB = pdb
177180
}
178181

@@ -275,6 +278,8 @@ func (ji *JobInfo) Clone() *JobInfo {
275278
Tasks: tasksMap{},
276279
}
277280

281+
ji.CreationTimestamp.DeepCopyInto(&info.CreationTimestamp)
282+
278283
for k, v := range ji.NodeSelector {
279284
info.NodeSelector[k] = v
280285
}

pkg/scheduler/plugins/gang/gang.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ func (gp *gangPlugin) OnSessionOpen(ssn *framework.Session) {
120120
}
121121

122122
if !lReady && !rReady {
123-
if lv.UID < rv.UID {
123+
if lv.CreationTimestamp.Equal(&rv.CreationTimestamp) {
124+
if lv.UID < rv.UID {
125+
return -1
126+
}
127+
} else if lv.CreationTimestamp.Before(&rv.CreationTimestamp) {
124128
return -1
125129
}
126130
return 1

0 commit comments

Comments
 (0)