Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from apache:master #24

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions pkg/scheduler/objects/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,10 @@ func (sq *Queue) isRoot() bool {
// Guard against going over max resources if set
func (sq *Queue) IncAllocatedResource(alloc *resources.Resource, nodeReported bool) error {
// check this queue: failure stops checks if the allocation is not part of a node addition
newAllocated := resources.Add(sq.allocatedResource, alloc)
if !nodeReported {
if !sq.resourceFitsMaxRes(newAllocated) {
return fmt.Errorf("allocation (%v) puts queue '%s' over maximum allocation (%v), current usage (%v)",
alloc, sq.QueuePath, sq.maxResource, sq.allocatedResource)
}
fit, newAllocated := sq.allocatedResFits(alloc)
if !nodeReported && !fit {
return fmt.Errorf("allocation (%v) puts queue '%s' over maximum allocation (%v), current usage (%v)",
alloc, sq.QueuePath, sq.maxResource, sq.allocatedResource)
}
// check the parent: need to pass before updating
if sq.parent != nil {
Expand All @@ -1020,11 +1018,12 @@ func (sq *Queue) IncAllocatedResource(alloc *resources.Resource, nodeReported bo
return nil
}

// small helper method to access sq.maxResource and avoid Clone() call
func (sq *Queue) resourceFitsMaxRes(res *resources.Resource) bool {
// small helper method to access sq.maxResource+sq.allocatedResource and avoid Clone() call
func (sq *Queue) allocatedResFits(res *resources.Resource) (bool, *resources.Resource) {
sq.RLock()
defer sq.RUnlock()
return sq.maxResource.FitInMaxUndef(res)
newAllocated := resources.Add(sq.allocatedResource, res)
return sq.maxResource.FitInMaxUndef(newAllocated), newAllocated
}

// DecAllocatedResource decrement the allocated resources for this queue (recursively)
Expand Down