From 01ed621e76e68902772be8a753b53a8268800ea0 Mon Sep 17 00:00:00 2001 From: "Da K. Ma" Date: Mon, 25 Feb 2019 09:51:22 +0800 Subject: [PATCH] Fixed duplicated queue in preempt/reclaim action. Signed-off-by: Da K. Ma --- pkg/scheduler/actions/preempt/preempt.go | 7 ++++--- pkg/scheduler/actions/reclaim/reclaim.go | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/scheduler/actions/preempt/preempt.go b/pkg/scheduler/actions/preempt/preempt.go index c339e2b47..fe2525239 100644 --- a/pkg/scheduler/actions/preempt/preempt.go +++ b/pkg/scheduler/actions/preempt/preempt.go @@ -48,14 +48,15 @@ func (alloc *preemptAction) Execute(ssn *framework.Session) { preemptorTasks := map[api.JobID]*util.PriorityQueue{} var underRequest []*api.JobInfo - var queues []*api.QueueInfo + queues := map[api.QueueID]*api.QueueInfo{} + for _, job := range ssn.Jobs { if queue, found := ssn.QueueIndex[job.Queue]; !found { continue - } else { + } else if _, existed := queues[queue.UID]; !existed { glog.V(3).Infof("Added Queue <%s> for Job <%s/%s>", queue.Name, job.Namespace, job.Name) - queues = append(queues, queue) + queues[queue.UID] = queue } if len(job.TaskStatusIndex[api.Pending]) != 0 { diff --git a/pkg/scheduler/actions/reclaim/reclaim.go b/pkg/scheduler/actions/reclaim/reclaim.go index 9a44fdff3..13c8c6011 100644 --- a/pkg/scheduler/actions/reclaim/reclaim.go +++ b/pkg/scheduler/actions/reclaim/reclaim.go @@ -43,6 +43,7 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) { defer glog.V(3).Infof("Leaving Reclaim ...") queues := util.NewPriorityQueue(ssn.QueueOrderFn) + queueMap := map[api.QueueID]*api.QueueInfo{} preemptorsMap := map[api.QueueID]*util.PriorityQueue{} preemptorTasks := map[api.JobID]*util.PriorityQueue{} @@ -57,9 +58,13 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) { job.Queue, job.Namespace, job.Name) continue } else { - glog.V(4).Infof("Added Queue <%s> for Job <%s/%s>", - queue.Name, job.Namespace, job.Name) - queues.Push(queue) + if _, existed := queueMap[queue.UID]; !existed { + glog.V(4).Infof("Added Queue <%s> for Job <%s/%s>", + queue.Name, job.Namespace, job.Name) + + queueMap[queue.UID] = queue + queues.Push(queue) + } } if len(job.TaskStatusIndex[api.Pending]) != 0 {