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