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

Order task, job, queue by CreationTimestamp first, then by UID #645

Merged
merged 3 commits into from
Mar 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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