From 17403b4f1e88dc9d8750620058d5ea0552112e61 Mon Sep 17 00:00:00 2001 From: TommyLike Date: Mon, 25 Mar 2019 18:53:49 +0800 Subject: [PATCH] Fix sub exception in reclaim and preempt --- pkg/scheduler/actions/preempt/preempt.go | 3 +-- pkg/scheduler/actions/reclaim/reclaim.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/actions/preempt/preempt.go b/pkg/scheduler/actions/preempt/preempt.go index 9b2132549..77c451491 100644 --- a/pkg/scheduler/actions/preempt/preempt.go +++ b/pkg/scheduler/actions/preempt/preempt.go @@ -231,10 +231,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() diff --git a/pkg/scheduler/actions/reclaim/reclaim.go b/pkg/scheduler/actions/reclaim/reclaim.go index e113a65a9..2f411d82e 100644 --- a/pkg/scheduler/actions/reclaim/reclaim.go +++ b/pkg/scheduler/actions/reclaim/reclaim.go @@ -165,10 +165,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>.",