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

[YUNIKORN-1990] Fixing intra-queue preemption: updating checkPreemption… #659

Closed
wants to merge 1 commit into from
Closed
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
35 changes: 33 additions & 2 deletions pkg/scheduler/objects/preemption.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,22 @@ func (p *Preemptor) checkPreemptionQueueGuarantees() bool {
}

currentQueue.AddAllocation(p.ask.GetAllocatedResource())
if !currentQueue.IsWithinMaxResource() {
return false
}
availableResource := p.headRoom.Clone()

// remove each allocation in turn, validating that at some point we free enough resources to allow this ask to fit
for _, snapshot := range queues {
for _, alloc := range snapshot.PotentialVictims {
snapshot.RemoveAllocation(alloc.GetAllocatedResource())
if currentQueue.IsWithinGuaranteedResource() {
return true
if snapshot.IsAtOrAboveGuaranteedResource() {
availableResource.AddTo(alloc.GetAllocatedResource())
if availableResource.FitInMaxUndef(p.ask.GetAllocatedResource()) {
return true
}
} else {
snapshot.AddAllocation(alloc.GetAllocatedResource())
}
}
}
Expand Down Expand Up @@ -715,6 +724,28 @@ func (qps *QueuePreemptionSnapshot) IsAtOrAboveGuaranteedResource() bool {
return resources.Equals(usedOrMax, used)
}

// IsWithinResourceRestruction determines if this queue is exceeding resource guarantees and below max resource.
func (qps *QueuePreemptionSnapshot) IsWithinMaxResource() bool {
if qps == nil {
return false
}
if qps.Parent != nil && !qps.Parent.IsWithinMaxResource() {
return false
}
guaranteed := qps.GetGuaranteedResource()
max := qps.GetMaxResource()
absMax := resources.ComponentWiseMax(guaranteed, max)
used := resources.Sub(qps.AllocatedResource, qps.PreemptingResource)

// if we don't fit, we're clearly above
if !resources.FitIn(absMax, used) {
return true
}

usedOrMax := resources.ComponentWiseMax(absMax, used)
return resources.Equals(usedOrMax, absMax)
}

// IsWithinGuaranteedResource determines if this queue is within its current resource guarantees
func (qps *QueuePreemptionSnapshot) IsWithinGuaranteedResource() bool {
if qps == nil {
Expand Down
Loading