Skip to content

Commit

Permalink
Fix Queue capability overuse when specify Job minAvailable less than …
Browse files Browse the repository at this point in the history
…replicas

Signed-off-by: Xu ZhengYu <zen-xu@outlook.com>
  • Loading branch information
zen-xu committed Sep 15, 2020
1 parent 5e0178b commit f8bb04c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/scheduler/plugins/proportion/proportion.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type queueAttr struct {
allocated *api.Resource
request *api.Resource
// inqueue represents the resource request of the inqueue job
inqueue *api.Resource
inqueue *api.Resource
capability *api.Resource
}

// GetJobMinResources return the min resources of podgroup.
Expand Down Expand Up @@ -94,6 +95,10 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
request: api.EmptyResource(),
inqueue: api.EmptyResource(),
}
if len(queue.Queue.Spec.Capability) != 0 {
attr.capability = api.NewResource(queue.Queue.Spec.Capability)
}

pp.queueOpts[job.Queue] = attr
klog.V(4).Infof("Added Queue <%s> attributes.", job.Queue)
}
Expand Down Expand Up @@ -161,11 +166,15 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
oldDeserved := attr.deserved.Clone()
attr.deserved.Add(remaining.Clone().Multi(float64(attr.weight) / float64(totalWeight)))

if attr.request.Less(attr.deserved) {
if attr.capability != nil && !attr.deserved.LessEqualStrict(attr.capability) {
attr.deserved = helpers.Min(attr.deserved, attr.capability)
attr.deserved = helpers.Min(attr.deserved, attr.request)
meet[attr.queueID] = struct{}{}
klog.V(4).Infof("queue <%s> is meet cause of the capability", attr.name)
} else if attr.request.Less(attr.deserved) {
attr.deserved = helpers.Min(attr.deserved, attr.request)
meet[attr.queueID] = struct{}{}
klog.V(4).Infof("queue <%s> is meet", attr.name)

}
pp.updateShare(attr)

Expand Down

0 comments on commit f8bb04c

Please sign in to comment.