Fixed a bug where quota headroom is tracked incorrectly. Only resources allocated towards a role's quota should be subtracted from `requiredHeadroom`. In addition to this, unreserved resources in the quota allocation stage may also contain resources that a role does not have quota for, they should not be subtracted from `requiredHeadroom`.
Review: https://reviews.apache.org/r/64792/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2324ec88 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2324ec88 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2324ec88 Branch: refs/heads/1.4.x Commit: 2324ec88686badfa854b3e3f233fa0dbbdfb0c1f Parents: 3d04409 Author: Meng Zhu <[email protected]> Authored: Thu Dec 21 17:27:30 2017 -0800 Committer: Benjamin Mahler <[email protected]> Committed: Wed May 2 16:44:15 2018 -0700 ---------------------------------------------------------------------- src/master/allocator/mesos/hierarchical.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/2324ec88/src/master/allocator/mesos/hierarchical.cpp ---------------------------------------------------------------------- diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp index de6a7e2..dade4ae 100644 --- a/src/master/allocator/mesos/hierarchical.cpp +++ b/src/master/allocator/mesos/hierarchical.cpp @@ -1896,13 +1896,15 @@ void HierarchicalAllocatorProcess::__allocate() offerable[frameworkId][role][slaveId] += resources; offeredSharedResources[slaveId] += resources.shared(); - unsatisfiedQuota -= newQuotaAllocation.createStrippedScalarQuantity(); + Resources newQuotaAllocationScalarQuantities = + newQuotaAllocation.createStrippedScalarQuantity(); + + unsatisfiedQuota -= newQuotaAllocationScalarQuantities; // Track quota headroom change. - Resources headroomDelta = + requiredHeadroom -= newQuotaAllocationScalarQuantities; + availableHeadroom -= resources.unreserved().createStrippedScalarQuantity(); - requiredHeadroom -= headroomDelta; - availableHeadroom -= headroomDelta; // Update the tracking of allocated reservations. //
