Skip to content

Commit c5f6bc8

Browse files
Merge pull request #971 from hzxuzhonghu/automated-cherry-pick-of-#959-#966-xu-release-1.0
Automated cherry pick of #959: fix bug of queue capability lose efficacy #966: Record Inqueue job resource request in queueAttr
2 parents b657c6b + 65375d5 commit c5f6bc8

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

pkg/scheduler/actions/enqueue/enqueue.go

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func (enqueue *Action) Execute(ssn *framework.Session) {
5555

5656
queues := util.NewPriorityQueue(ssn.QueueOrderFn)
5757
queueMap := map[api.QueueID]*api.QueueInfo{}
58-
5958
jobsMap := map[api.QueueID]*util.PriorityQueue{}
6059

6160
for _, job := range ssn.Jobs {

pkg/scheduler/plugins/proportion/proportion.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package proportion
1919
import (
2020
"k8s.io/klog"
2121

22+
"volcano.sh/volcano/pkg/apis/scheduling"
2223
"volcano.sh/volcano/pkg/scheduler/api"
2324
"volcano.sh/volcano/pkg/scheduler/api/helpers"
2425
"volcano.sh/volcano/pkg/scheduler/framework"
@@ -44,6 +45,8 @@ type queueAttr struct {
4445
deserved *api.Resource
4546
allocated *api.Resource
4647
request *api.Resource
48+
// inqueue represents the resource request of the inqueue job
49+
inqueue *api.Resource
4750
}
4851

4952
// New return proportion action
@@ -70,7 +73,6 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
7073
// Build attributes for Queues.
7174
for _, job := range ssn.Jobs {
7275
klog.V(4).Infof("Considering Job <%s/%s>.", job.Namespace, job.Name)
73-
7476
if _, found := pp.queueOpts[job.Queue]; !found {
7577
queue := ssn.Queues[job.Queue]
7678
attr := &queueAttr{
@@ -81,25 +83,29 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
8183
deserved: api.EmptyResource(),
8284
allocated: api.EmptyResource(),
8385
request: api.EmptyResource(),
86+
inqueue: api.EmptyResource(),
8487
}
8588
pp.queueOpts[job.Queue] = attr
8689
klog.V(4).Infof("Added Queue <%s> attributes.", job.Queue)
8790
}
8891

92+
attr := pp.queueOpts[job.Queue]
8993
for status, tasks := range job.TaskStatusIndex {
9094
if api.AllocatedStatus(status) {
9195
for _, t := range tasks {
92-
attr := pp.queueOpts[job.Queue]
9396
attr.allocated.Add(t.Resreq)
9497
attr.request.Add(t.Resreq)
9598
}
9699
} else if status == api.Pending {
97100
for _, t := range tasks {
98-
attr := pp.queueOpts[job.Queue]
99101
attr.request.Add(t.Resreq)
100102
}
101103
}
102104
}
105+
106+
if job.PodGroup.Status.Phase == scheduling.PodGroupInqueue {
107+
attr.inqueue.Add(api.NewResource(*job.PodGroup.Spec.MinResources))
108+
}
103109
}
104110

105111
// Record metrics
@@ -243,7 +249,11 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
243249

244250
minReq := api.NewResource(*job.PodGroup.Spec.MinResources)
245251
// The queue resource quota limit has not reached
246-
return minReq.Add(attr.allocated).LessEqual(api.NewResource(queue.Queue.Spec.Capability))
252+
inqueue := minReq.Add(attr.allocated).Add(attr.inqueue).LessEqual(api.NewResource(queue.Queue.Spec.Capability))
253+
if inqueue {
254+
attr.inqueue.Add(api.NewResource(*job.PodGroup.Spec.MinResources))
255+
}
256+
return inqueue
247257
})
248258

249259
// Register event handlers.

0 commit comments

Comments
 (0)