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 {