Check if slave is marked gone during reregistration.

This commit adds checks that test whether a
re-registering agent is being marked gone or has been
marked gone during the re-registration attempt.

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


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

Branch: refs/heads/master
Commit: b612e9d511daa2a5f99ef984c7eb9aeeda79c4db
Parents: 63e3336
Author: Benno Evers <bev...@mesosphere.com>
Authored: Tue Dec 5 13:56:14 2017 -0800
Committer: Vinod Kone <vinodk...@gmail.com>
Committed: Tue Dec 5 13:58:52 2017 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b612e9d5/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 6a52aad..f9740e0 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -6472,6 +6472,24 @@ void Master::_reregisterSlave(
     return;
   }
 
+  if (slaves.markingGone.contains(slaveInfo.id())) {
+    LOG(INFO)
+      << "Ignoring re-register agent message from agent "
+      << slaveInfo.id() << " at " << pid << " ("
+      << slaveInfo.hostname() << ") as a gone operation is already in 
progress";
+    return;
+  }
+
+  if (slaves.gone.contains(slaveInfo.id())) {
+    LOG(WARNING) << "Refusing re-registration of agent at " << pid
+                 << " because it is already marked gone";
+
+    ShutdownMessage message;
+    message.set_message("Agent has been marked gone");
+    send(pid, message);
+    return;
+  }
+
   VLOG(1) << "Authorized re-registration of agent " << slaveInfo.id()
           << " at " << pid << " (" << slaveInfo.hostname() << ")";
 
@@ -6651,6 +6669,24 @@ void Master::__reregisterSlave(
   // should ever fail.
   CHECK(future.get());
 
+  if (slaves.markingGone.contains(slaveInfo.id())) {
+    LOG(INFO)
+      << "Ignoring re-register agent message from agent "
+      << slaveInfo.id() << " at " << pid << " ("
+      << slaveInfo.hostname() << ") as a gone operation is already in 
progress";
+    return;
+  }
+
+  if (slaves.gone.contains(slaveInfo.id())) {
+    LOG(WARNING) << "Refusing re-registration of agent at " << pid
+                 << " because it is already marked gone";
+
+    ShutdownMessage message;
+    message.set_message("Agent has been marked gone");
+    send(pid, message);
+    return;
+  }
+
   VLOG(1) << "Re-admitted agent " << slaveInfo.id() << " at " << pid
           << " (" << slaveInfo.hostname() << ")";
 
@@ -6851,6 +6887,24 @@ void Master::___reregisterSlave(
   VLOG(1) << "Registry updated for slave " << slaveInfo.id() << " at " << pid
           << "(" << slaveInfo.hostname() << ")";
 
+  if (slaves.markingGone.contains(slaveInfo.id())) {
+    LOG(INFO)
+      << "Ignoring re-register agent message from agent "
+      << slaveInfo.id() << " at " << pid << " ("
+      << slaveInfo.hostname() << ") as a gone operation is already in 
progress";
+    return;
+  }
+
+  if (slaves.gone.contains(slaveInfo.id())) {
+    LOG(WARNING) << "Refusing re-registration of agent at " << pid
+                 << " because it is already marked gone";
+
+    ShutdownMessage message;
+    message.set_message("Agent has been marked gone");
+    send(pid, message);
+    return;
+  }
+
   if (!slaves.registered.contains(slaveInfo.id())) {
     LOG(WARNING)
       << "Dropping ongoing re-registration attempt of slave " << slaveInfo.id()

Reply via email to