[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesos-commits
Subject:    [1/2] mesos git commit: Fixed a bug where quota headroom is under-calculated.
From:       bmahler () apache ! org
Date:       2018-02-27 4:33:13
Message-ID: fb3ba69cbc7a46c3b3507eafb8421d13 () git ! apache ! org
[Download RAW message or body]

Repository: mesos
Updated Branches:
  refs/heads/master c97ef907f -> a4df5d43e


Fixed a bug where quota headroom is under-calculated.

When calculating the quota headroom, we failed to consider
ancestor's reservation allocated to the child. This leads
to under-calculation of available headroom and excessive
resources being set aside for headroom. See MESOS-8604.

This patches fixes this issue by counting ancestor's reservation
allocated to the child as allocated-reservation even though
the child itself has no reservation.

Review: https://reviews.apache.org/r/65806/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a57c3c9a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a57c3c9a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a57c3c9a

Branch: refs/heads/master
Commit: a57c3c9a7cb1f531d39178086d004975004871e0
Parents: c97ef90
Author: Meng Zhu <mzhu@mesosphere.io>
Authored: Mon Feb 26 19:25:09 2018 -0800
Committer: Benjamin Mahler <bmahler@apache.org>
Committed: Mon Feb 26 19:42:38 2018 -0800

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.cpp | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a57c3c9a/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 80e0a34..58aa83f 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -1673,30 +1673,34 @@ void HierarchicalAllocatorProcess::__allocate()
       roleSorter->allocationScalarQuantities(role).toUnreserved();
   }
 
-  // Subtract all unallocated reservations.
-  foreachkey (const string& role, reservationScalarQuantities) {
+  // Calculate total allocated reservations. Note that we need to ensure
+  // we count a reservation for "a" being allocated to "a/b", therefore
+  // we cannot simply loop over the reservations' roles.
+  Resources totalAllocatedReservationScalarQuantities;
+  foreachkey (const string& role, roles) {
     hashmap<SlaveID, Resources> allocations;
     if (quotaRoleSorter->contains(role)) {
       allocations = quotaRoleSorter->allocation(role);
     } else if (roleSorter->contains(role)) {
       allocations = roleSorter->allocation(role);
+    } else {
+      continue; // This role has no allocation.
     }
 
-    Resources unallocatedReservations =
-      reservationScalarQuantities.get(role).getOrElse(Resources());
-
     foreachvalue (const Resources& resources, allocations) {
       // NOTE: `totalScalarQuantities` omits dynamic reservation,
       // persistent volume info, and allocation info. We additionally
       // remove the static reservations here via `toUnreserved()`.
-      unallocatedReservations -=
+      totalAllocatedReservationScalarQuantities +=
         resources.reserved().createStrippedScalarQuantity().toUnreserved();
     }
-
-    // Subtract the unallocated reservations for this role from the headroom.
-    availableHeadroom -= unallocatedReservations;
   }
 
+  // Subtract total unallocated reservations.
+  availableHeadroom -=
+    Resources::sum(reservationScalarQuantities) -
+    totalAllocatedReservationScalarQuantities;
+
   // Subtract revocable resources.
   foreachvalue (const Slave& slave, slaves) {
     // NOTE: `totalScalarQuantities` omits dynamic reservation,

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic