Repository: mesos
Updated Branches:
  refs/heads/master 90ce79767 -> 20c3c34b0


Fixed a crash when metrics race with quota removal.

This patch addresses a race condition in which the removal of
a role from the allocator's quota sorter races with execution
of a callback tied to a `PullGauge`. The gauge's callback
assumed that the role would be present in the sorter, but it's
possible for the role to be removed before the callback is
executed.

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


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

Branch: refs/heads/master
Commit: 20c3c34b08ade3b9cf93d55c1f81c0413eb268c4
Parents: 90ce797
Author: Greg Mann <g...@mesosphere.io>
Authored: Mon May 14 09:21:26 2018 -0700
Committer: Greg Mann <gregorywm...@gmail.com>
Committed: Mon May 14 09:21:29 2018 -0700

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/20c3c34b/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp 
b/src/master/allocator/mesos/hierarchical.cpp
index 1000968..c221999 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -2512,8 +2512,14 @@ double HierarchicalAllocatorProcess::_quota_allocated(
     const string& role,
     const string& resource)
 {
+  if (!roleSorter->contains(role)) {
+    // This can occur when execution of this callback races with removal of the
+    // metric for a role which does not have any associated frameworks.
+    return 0.;
+  }
+
   Option<Value::Scalar> used =
-    quotaRoleSorter->allocationScalarQuantities(role)
+    roleSorter->allocationScalarQuantities(role)
       .get<Value::Scalar>(resource);
 
   return used.isSome() ? used->value() : 0;

Reply via email to