From f972385117c11205076584ab1dad0c5855dc846e Mon Sep 17 00:00:00 2001 From: Jun Gong Date: Mon, 18 Mar 2019 09:17:30 +0800 Subject: [PATCH 1/3] Order task by CreationTimestamp first, then by UID --- pkg/scheduler/framework/session_plugins.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/scheduler/framework/session_plugins.go b/pkg/scheduler/framework/session_plugins.go index dfbe655c6..3f4d68bd5 100644 --- a/pkg/scheduler/framework/session_plugins.go +++ b/pkg/scheduler/framework/session_plugins.go @@ -272,11 +272,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 { From 1bb080f9dd2488af0d4315486efee840dc1be708 Mon Sep 17 00:00:00 2001 From: Jun Gong Date: Mon, 18 Mar 2019 09:19:46 +0800 Subject: [PATCH 2/3] Order queue by CreationTimestamp first, then by UID --- pkg/scheduler/framework/session_plugins.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/scheduler/framework/session_plugins.go b/pkg/scheduler/framework/session_plugins.go index 3f4d68bd5..edcedadf6 100644 --- a/pkg/scheduler/framework/session_plugins.go +++ b/pkg/scheduler/framework/session_plugins.go @@ -241,11 +241,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 { From 1814be6fd1038e1f43f47199bc9145d00a9028d8 Mon Sep 17 00:00:00 2001 From: Jun Gong Date: Mon, 18 Mar 2019 09:20:50 +0800 Subject: [PATCH 3/3] Order job by CreationTimestamp first, then by UID --- pkg/scheduler/framework/session_plugins.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/framework/session_plugins.go b/pkg/scheduler/framework/session_plugins.go index edcedadf6..3520a2c2f 100644 --- a/pkg/scheduler/framework/session_plugins.go +++ b/pkg/scheduler/framework/session_plugins.go @@ -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 {