Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#464 from adam-marek/amarek-orde…
Browse files Browse the repository at this point in the history
…ring

Order gang scheduled jobs based on time of arrival
  • Loading branch information
k8s-ci-robot authored Nov 5, 2018
2 parents 077fa74 + cc21628 commit c0d25ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package api

import (
"fmt"

"k8s.io/api/core/v1"
policyv1 "k8s.io/api/policy/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

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

PodGroup *arbcorev1.PodGroup
CreationTimestamp metav1.Time
PodGroup *arbcorev1.PodGroup

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

ji.CreationTimestamp = pg.GetCreationTimestamp()
ji.PodGroup = pg
}

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

ji.CreationTimestamp = pdb.GetCreationTimestamp()
ji.PDB = pdb
}

Expand Down Expand Up @@ -275,6 +278,8 @@ func (ji *JobInfo) Clone() *JobInfo {
Tasks: tasksMap{},
}

ji.CreationTimestamp.DeepCopyInto(&info.CreationTimestamp)

for k, v := range ji.NodeSelector {
info.NodeSelector[k] = v
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/scheduler/plugins/gang/gang.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ func (gp *gangPlugin) OnSessionOpen(ssn *framework.Session) {
}

if !lReady && !rReady {
if lv.UID < rv.UID {
if lv.CreationTimestamp.Equal(&rv.CreationTimestamp) {
if lv.UID < rv.UID {
return -1
}
} else if lv.CreationTimestamp.Before(&rv.CreationTimestamp) {
return -1
}
return 1
Expand Down

0 comments on commit c0d25ab

Please sign in to comment.