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 2014/04/17 04:28:18 UTC

[5/6] git commit: If a non-strict registry is in use, do not inform frameworks that slaves are lost if they do not re-register after a failover.

If a non-strict registry is in use, do not inform frameworks that slaves are lost if they do not re-register after a failover.

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


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

Branch: refs/heads/master
Commit: a3783604289dd7b60c15928edb67f4ced7de25a3
Parents: f0226b3
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Tue Apr 15 11:28:38 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Apr 16 19:17:04 2014 -0700

----------------------------------------------------------------------
 src/master/master.cpp | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a3783604/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index d7d200b..0335b34 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -757,6 +757,12 @@ void Master::visit(const MessageEvent& event)
 }
 
 
+void fail(const string& message, const string& failure)
+{
+  LOG(FATAL) << message << ": " << failure;
+}
+
+
 Future<Nothing> Master::recover()
 {
   if (!elected()) {
@@ -842,21 +848,28 @@ void Master::recoveredSlavesTimeout(const Registry& registry)
                  << "within the timeout; removing it from the registrar";
 
     slaves.recovered.erase(slave.info().id());
-    slaves.removing.insert(slave.info().id());
 
-    registrar->apply(Owned<Operation>(new RemoveSlave(slave.info())))
-      .onAny(defer(self(),
-                   &Self::_removeSlave,
-                   slave.info(),
-                   vector<StatusUpdate>(), // No TASK_LOST updates to send.
-                   lambda::_1));
-  }
-}
+    if (flags.registry_strict) {
+      slaves.removing.insert(slave.info().id());
 
+      registrar->apply(Owned<Operation>(new RemoveSlave(slave.info())))
+        .onAny(defer(self(),
+                     &Self::_removeSlave,
+                     slave.info(),
+                     vector<StatusUpdate>(), // No TASK_LOST updates to send.
+                     lambda::_1));
+    } else {
+      // When a non-strict registry is in use, we want to ensure the
+      // registry is used in a write-only manner. Therefore we remove
+      // the slave from the registry but we do not inform the
+      // framework.
+      const string& message =
+        "Failed to remove slave " + stringify(slave.info().id());
 
-void fail(const string& message, const string& failure)
-{
-  LOG(FATAL) << message << ": " << failure;
+      registrar->apply(Owned<Operation>(new RemoveSlave(slave.info())))
+        .onFailed(lambda::bind(fail, message, lambda::_1));
+    }
+  }
 }