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

Commit 3f7c0c2

Browse files
authored
Merge pull request #601 from k82cn/automated-cherry-pick-of-#600-upstream-release-0.4
Automated cherry pick of #600: Fixed duplicated queue in preempt/reclaim action.
2 parents 68b458c + 01ed621 commit 3f7c0c2

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

pkg/scheduler/actions/preempt/preempt.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ func (alloc *preemptAction) Execute(ssn *framework.Session) {
4848
preemptorTasks := map[api.JobID]*util.PriorityQueue{}
4949

5050
var underRequest []*api.JobInfo
51-
var queues []*api.QueueInfo
51+
queues := map[api.QueueID]*api.QueueInfo{}
52+
5253
for _, job := range ssn.Jobs {
5354
if queue, found := ssn.QueueIndex[job.Queue]; !found {
5455
continue
55-
} else {
56+
} else if _, existed := queues[queue.UID]; !existed {
5657
glog.V(3).Infof("Added Queue <%s> for Job <%s/%s>",
5758
queue.Name, job.Namespace, job.Name)
58-
queues = append(queues, queue)
59+
queues[queue.UID] = queue
5960
}
6061

6162
if len(job.TaskStatusIndex[api.Pending]) != 0 {

pkg/scheduler/actions/reclaim/reclaim.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) {
4343
defer glog.V(3).Infof("Leaving Reclaim ...")
4444

4545
queues := util.NewPriorityQueue(ssn.QueueOrderFn)
46+
queueMap := map[api.QueueID]*api.QueueInfo{}
4647

4748
preemptorsMap := map[api.QueueID]*util.PriorityQueue{}
4849
preemptorTasks := map[api.JobID]*util.PriorityQueue{}
@@ -57,9 +58,13 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) {
5758
job.Queue, job.Namespace, job.Name)
5859
continue
5960
} else {
60-
glog.V(4).Infof("Added Queue <%s> for Job <%s/%s>",
61-
queue.Name, job.Namespace, job.Name)
62-
queues.Push(queue)
61+
if _, existed := queueMap[queue.UID]; !existed {
62+
glog.V(4).Infof("Added Queue <%s> for Job <%s/%s>",
63+
queue.Name, job.Namespace, job.Name)
64+
65+
queueMap[queue.UID] = queue
66+
queues.Push(queue)
67+
}
6368
}
6469

6570
if len(job.TaskStatusIndex[api.Pending]) != 0 {

0 commit comments

Comments
 (0)