@@ -18,6 +18,8 @@ package proportion
18
18
19
19
import (
20
20
"k8s.io/klog"
21
+
22
+ "volcano.sh/volcano/pkg/apis/scheduling"
21
23
"volcano.sh/volcano/pkg/scheduler/api"
22
24
"volcano.sh/volcano/pkg/scheduler/api/helpers"
23
25
"volcano.sh/volcano/pkg/scheduler/framework"
@@ -43,6 +45,8 @@ type queueAttr struct {
43
45
deserved * api.Resource
44
46
allocated * api.Resource
45
47
request * api.Resource
48
+ // inqueue represents the resource request of the inqueue job
49
+ inqueue * api.Resource
46
50
}
47
51
48
52
// New return proportion action
@@ -69,7 +73,6 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
69
73
// Build attributes for Queues.
70
74
for _ , job := range ssn .Jobs {
71
75
klog .V (4 ).Infof ("Considering Job <%s/%s>." , job .Namespace , job .Name )
72
-
73
76
if _ , found := pp .queueOpts [job .Queue ]; ! found {
74
77
queue := ssn .Queues [job .Queue ]
75
78
attr := & queueAttr {
@@ -80,25 +83,29 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
80
83
deserved : api .EmptyResource (),
81
84
allocated : api .EmptyResource (),
82
85
request : api .EmptyResource (),
86
+ inqueue : api .EmptyResource (),
83
87
}
84
88
pp .queueOpts [job .Queue ] = attr
85
89
klog .V (4 ).Infof ("Added Queue <%s> attributes." , job .Queue )
86
90
}
87
91
92
+ attr := pp .queueOpts [job .Queue ]
88
93
for status , tasks := range job .TaskStatusIndex {
89
94
if api .AllocatedStatus (status ) {
90
95
for _ , t := range tasks {
91
- attr := pp .queueOpts [job .Queue ]
92
96
attr .allocated .Add (t .Resreq )
93
97
attr .request .Add (t .Resreq )
94
98
}
95
99
} else if status == api .Pending {
96
100
for _ , t := range tasks {
97
- attr := pp .queueOpts [job .Queue ]
98
101
attr .request .Add (t .Resreq )
99
102
}
100
103
}
101
104
}
105
+
106
+ if job .PodGroup .Status .Phase == scheduling .PodGroupInqueue {
107
+ attr .inqueue .Add (api .NewResource (* job .PodGroup .Spec .MinResources ))
108
+ }
102
109
}
103
110
104
111
// Record metrics
@@ -242,7 +249,11 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
242
249
243
250
minReq := api .NewResource (* job .PodGroup .Spec .MinResources )
244
251
// The queue resource quota limit has not reached
245
- return minReq .Add (attr .allocated ).Add (ssn .InqueueJobResource [job .Queue ]).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
246
257
})
247
258
248
259
// Register event handlers.
0 commit comments