Some extra safety around negative numbers
An extra check that available is > 0, not just != 0. Also, when rebalancing subrequests after a grant, if the grant was not made, set the value of the subrequest to 0, and use that when adjusting the amount available for the provider and amounts of other subrequests. In the case that a subrequest was for a negative value, it could cause the total request amount as well as the provider's available amount to increase. Now the negative case is handled as a grant of 0. Change-Id: I83c56b35e02defaba8a7338dcdf17363d687266f
This commit is contained in:
parent
80675bd315
commit
ed29412ed2
@ -173,7 +173,7 @@ class AllocationProvider(object):
|
||||
|
||||
for w in waiters:
|
||||
w = w[0]
|
||||
if self.available:
|
||||
if self.available > 0:
|
||||
w.grant(min(int(w.amount), self.available))
|
||||
else:
|
||||
reqs.append(w)
|
||||
@ -309,6 +309,7 @@ class AllocationSubRequest(object):
|
||||
self.provider.grants.append(grant)
|
||||
else:
|
||||
grant = None
|
||||
amount = 0
|
||||
self.amount = amount
|
||||
# Adjust provider and request values accordingly.
|
||||
self.request.amount -= amount
|
||||
|
Loading…
x
Reference in New Issue
Block a user