You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/10/12 01:57:08 UTC

mesos git commit: Fixed race in getting metrics for dominant share.

Repository: mesos
Updated Branches:
  refs/heads/master af2d40628 -> 857d82f64


Fixed race in getting metrics for dominant share.

When calculate share for dominant share metrics, the client
may have been removed if the dispatch occurs after the client
is removed but before the metric is removed.

The fix is checking if client exist or not before calculate
share for dominant share metrics.

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


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

Branch: refs/heads/master
Commit: 857d82f641e0dbcae09e0d04f8f8a70371990d8e
Parents: af2d406
Author: Guangya Liu <gy...@gmail.com>
Authored: Tue Oct 11 18:56:42 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Oct 11 18:56:42 2016 -0700

----------------------------------------------------------------------
 src/master/allocator/sorter/drf/metrics.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/857d82f6/src/master/allocator/sorter/drf/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/metrics.cpp b/src/master/allocator/sorter/drf/metrics.cpp
index baede07..15aab32 100644
--- a/src/master/allocator/sorter/drf/metrics.cpp
+++ b/src/master/allocator/sorter/drf/metrics.cpp
@@ -61,7 +61,14 @@ void Metrics::add(const string& client)
   Gauge gauge(
       path::join(prefix, client, "/shares/", "/dominant"),
       defer(context, [this, client]() {
-        return sorter->calculateShare(client);
+        // The client may have been removed if the dispatch
+        // occurs after the client is removed but before the
+        // metric is removed.
+        if (sorter->contains(client)) {
+          return sorter->calculateShare(client);
+        }
+
+        return 0.0;
       }));
 
   dominantShares.put(client, gauge);