Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#645 from hex108/cleanup
Browse files Browse the repository at this point in the history
Order task, job, queue by CreationTimestamp first, then by UID
  • Loading branch information
k8s-ci-robot authored Mar 18, 2019
2 parents 7c08464 + dcc9dbf commit 2234ece
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions pkg/scheduler/framework/session_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,14 @@ func (ssn *Session) JobOrderFn(l, r interface{}) bool {
}
}

// If no job order funcs, order job by UID.
// If no job order funcs, order job by CreationTimestamp first, then by UID.
lv := l.(*api.JobInfo)
rv := r.(*api.JobInfo)

if lv.CreationTimestamp.Equal(&rv.CreationTimestamp) {
return lv.UID < rv.UID
} else {
return lv.CreationTimestamp.Before(&rv.CreationTimestamp)
}

return lv.CreationTimestamp.Before(&rv.CreationTimestamp)
}

func (ssn *Session) QueueOrderFn(l, r interface{}) bool {
Expand All @@ -241,11 +240,14 @@ func (ssn *Session) QueueOrderFn(l, r interface{}) bool {
}
}

// If no queue order funcs, order queue by UID.
// If no queue order funcs, order queue by CreationTimestamp first, then by UID.
lv := l.(*api.QueueInfo)
rv := r.(*api.QueueInfo)

return lv.UID < rv.UID
if lv.Queue.CreationTimestamp.Equal(&rv.Queue.CreationTimestamp) {
return lv.UID < rv.UID
} else {
return lv.Queue.CreationTimestamp.Before(&rv.Queue.CreationTimestamp)
}
}

func (ssn *Session) TaskCompareFns(l, r interface{}) int {
Expand All @@ -272,11 +274,14 @@ func (ssn *Session) TaskOrderFn(l, r interface{}) bool {
return res < 0
}

// If no task order funcs, order task by UID.
// If no task order funcs, order task by CreationTimestamp first, then by UID.
lv := l.(*api.TaskInfo)
rv := r.(*api.TaskInfo)

return lv.UID < rv.UID
if lv.Pod.CreationTimestamp.Equal(&rv.Pod.CreationTimestamp) {
return lv.UID < rv.UID
} else {
return lv.Pod.CreationTimestamp.Before(&rv.Pod.CreationTimestamp)
}
}

func (ssn *Session) PredicateFn(task *api.TaskInfo, node *api.NodeInfo) error {
Expand Down

0 comments on commit 2234ece

Please sign in to comment.