You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2014/04/25 19:14:59 UTC

git commit: Added a message string to the slave ShutdownMessage.

Repository: mesos
Updated Branches:
  refs/heads/master 96f8640b8 -> 3847dd8bd


Added a message string to the slave ShutdownMessage.

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


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

Branch: refs/heads/master
Commit: 3847dd8bdc621866b06d82e1bb52beb011bca659
Parents: 96f8640
Author: Adam B <ad...@mesosphere.io>
Authored: Fri Apr 25 10:14:49 2014 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Fri Apr 25 10:14:49 2014 -0700

----------------------------------------------------------------------
 src/master/master.cpp       | 39 +++++++++++++++++++++++++++++++--------
 src/master/master.hpp       |  3 ++-
 src/messages/messages.proto |  4 +++-
 src/slave/slave.cpp         |  8 +++++---
 src/slave/slave.hpp         |  2 +-
 src/tests/cluster.hpp       |  5 ++++-
 6 files changed, 46 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3847dd8b/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index beb8a04..890873b 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -192,7 +192,7 @@ protected:
 
   void shutdown()
   {
-    dispatch(master, &Master::shutdownSlave, slaveId);
+    dispatch(master, &Master::shutdownSlave, slaveId, "health check timed out");
   }
 
 private:
@@ -2127,7 +2127,12 @@ void Master::_registerSlave(
                << " (" << slaveInfo.hostname() << ") was not admitted, "
                << "asking to shut down";
     slaves.deactivated.put(slaveInfo.id(), Nothing());
-    send(pid, ShutdownMessage());
+
+    ShutdownMessage message;
+    message.set_message(
+        "Slave attempted to register but got duplicate slave id " +
+        stringify(slaveInfo.id()));
+    send(pid, message);
   } else {
     Slave* slave = new Slave(slaveInfo, slaveInfo.id(), pid, Clock::now());
 
@@ -2158,7 +2163,10 @@ void Master::reregisterSlave(
     LOG(WARNING) << "Slave " << slaveId << " at " << from
                  << " (" << slaveInfo.hostname() << ") attempted to "
                  << "re-register after deactivation; shutting it down";
-    reply(ShutdownMessage());
+
+    ShutdownMessage message;
+    message.set_message("Slave attempted to re-register after deactivation");
+    reply(message);
     return;
   }
 
@@ -2270,7 +2278,12 @@ void Master::_reregisterSlave(
                  << pid << " (" << slaveInfo.hostname() << ") could not be"
                  << " readmitted; shutting it down";
     slaves.deactivated.put(slaveInfo.id(), Nothing());
-    send(pid, ShutdownMessage());
+
+    ShutdownMessage message;
+    message.set_message(
+        "Slave attempted to re-register with unknown slave id " +
+        stringify(slaveInfo.id()));
+    send(pid, message);
   } else {
     // Re-admission succeeded.
     Slave* slave = new Slave(slaveInfo, slaveInfo.id(), pid, Clock::now());
@@ -2330,7 +2343,11 @@ void Master::statusUpdate(const StatusUpdate& update, const UPID& pid)
                  << " from deactivated slave " << pid
                  << " with id " << update.slave_id() << " ; asking slave "
                  << " to shutdown";
-    send(pid, ShutdownMessage());
+
+    ShutdownMessage message;
+    message.set_message("Status update from unknown slave");
+    send(pid, message);
+
     stats.invalidStatusUpdates++;
     return;
   }
@@ -2416,7 +2433,10 @@ void Master::exitedExecutor(
                  << "' of framework " << frameworkId
                  << " on deactivated slave " << slaveId
                  << " ; asking slave to shutdown";
-    reply(ShutdownMessage());
+
+    ShutdownMessage message;
+    message.set_message("Executor exited message from unknown slave");
+    reply(message);
     return;
   }
 
@@ -2467,7 +2487,7 @@ void Master::exitedExecutor(
 }
 
 
-void Master::shutdownSlave(const SlaveID& slaveId)
+void Master::shutdownSlave(const SlaveID& slaveId, const string& message)
 {
   if (!slaves.activated.contains(slaveId)) {
     // Possible when the SlaveObserver dispatched to shutdown a slave,
@@ -2481,7 +2501,10 @@ void Master::shutdownSlave(const SlaveID& slaveId)
 
   LOG(WARNING) << "Shutting down slave " << slaveId << " at " << slave->pid;
 
-  send(slave->pid, ShutdownMessage());
+  ShutdownMessage message_;
+  message_.set_message(message);
+  send(slave->pid, message_);
+
   removeSlave(slave);
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/3847dd8b/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 7c41de2..9808378 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -163,7 +163,8 @@ public:
       const ExecutorID& executorId,
       int32_t status);
   void shutdownSlave(
-      const SlaveID& slaveId);
+      const SlaveID& slaveId,
+      const std::string& message);
 
   // TODO(bmahler): It would be preferred to use a unique libprocess
   // Process identifier (PID is not sufficient) for identifying the

http://git-wip-us.apache.org/repos/asf/mesos/blob/3847dd8b/src/messages/messages.proto
----------------------------------------------------------------------
diff --git a/src/messages/messages.proto b/src/messages/messages.proto
index bba17a9..6f6e570 100644
--- a/src/messages/messages.proto
+++ b/src/messages/messages.proto
@@ -335,7 +335,9 @@ message FrameworkExpiredMessage {
 }
 
 
-message ShutdownMessage {}
+message ShutdownMessage {
+  optional string message = 1;
+}
 
 
 message AuthenticateMessage {

http://git-wip-us.apache.org/repos/asf/mesos/blob/3847dd8b/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 6fbc970..6bcf64f 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -344,7 +344,8 @@ void Slave::initialize()
       &ExecutorToFrameworkMessage::data);
 
   install<ShutdownMessage>(
-      &Slave::shutdown);
+      &Slave::shutdown,
+      &ShutdownMessage::message);
 
   // Install the ping message handler.
   install("PING", &Slave::ping);
@@ -416,7 +417,7 @@ void Slave::finalize()
 }
 
 
-void Slave::shutdown(const UPID& from)
+void Slave::shutdown(const UPID& from, const string& message)
 {
   // Allow shutdown message only if
   // 1) Its a message received from the registered master or
@@ -428,7 +429,8 @@ void Slave::shutdown(const UPID& from)
     return;
   }
 
-  LOG(INFO) << "Slave asked to shut down by " << from;
+  LOG(INFO) << "Slave asked to shut down by " << from
+            << (message.empty() ? "" : " because '" + message + "'");
 
   state = TERMINATING;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/3847dd8b/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 34c4048..90b2c83 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -87,7 +87,7 @@ public:
 
   virtual ~Slave();
 
-  void shutdown(const process::UPID& from);
+  void shutdown(const process::UPID& from, const std::string& message);
 
   void registered(const process::UPID& from, const SlaveID& slaveId);
   void reregistered(const process::UPID& from, const SlaveID& slaveId);

http://git-wip-us.apache.org/repos/asf/mesos/blob/3847dd8b/src/tests/cluster.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cluster.hpp b/src/tests/cluster.hpp
index 5e905f5..eedb012 100644
--- a/src/tests/cluster.hpp
+++ b/src/tests/cluster.hpp
@@ -557,7 +557,10 @@ inline Try<Nothing> Cluster::Slaves::stop(
   Slave slave = slaves[pid];
 
   if (shutdown) {
-    process::dispatch(slave.slave, &slave::Slave::shutdown, process::UPID());
+    process::dispatch(slave.slave,
+                      &slave::Slave::shutdown,
+                      process::UPID(),
+                      "");
   } else {
     process::terminate(slave.slave);
   }