Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#660 from TommyLike/bug/fix_sub_…
Browse files Browse the repository at this point in the history
…error

Fix Resource Sub exception in Reclaim&Preempt Actions
  • Loading branch information
k8s-ci-robot authored Mar 27, 2019
2 parents 7e5dec1 + 09f78a0 commit d78f760
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/scheduler/actions/preempt/preempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,9 @@ func preempt(
}
preempted.Add(preemptee.Resreq)
// If reclaimed enough resources, break loop to avoid Sub panic.
if resreq.LessEqual(preemptee.Resreq) {
if resreq.LessEqual(preempted) {
break
}
resreq.Sub(preemptee.Resreq)
}

metrics.RegisterPreemptionAttempts()
Expand Down
3 changes: 1 addition & 2 deletions pkg/scheduler/actions/reclaim/reclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) {
}
reclaimed.Add(reclaimee.Resreq)
// If reclaimed enough resources, break loop to avoid Sub panic.
if resreq.LessEqual(reclaimee.Resreq) {
if resreq.LessEqual(reclaimed) {
break
}
resreq.Sub(reclaimee.Resreq)
}

glog.V(3).Infof("Reclaimed <%v> for task <%s/%s> requested <%v>.",
Expand Down

0 comments on commit d78f760

Please sign in to comment.