You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ne...@apache.org on 2017/05/31 18:42:00 UTC

[10/10] mesos git commit: Simplified master logic for agent re-registration.

Simplified master logic for agent re-registration.

Now that 0.x agents are not supported, the master logic can be
simplified somewhat.

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


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

Branch: refs/heads/master
Commit: 8054de1967a09bc04b316e183c74cf56a4ee493e
Parents: 7dec5f4
Author: Neil Conway <ne...@gmail.com>
Authored: Mon May 15 16:39:31 2017 -0700
Committer: Neil Conway <ne...@gmail.com>
Committed: Wed May 31 11:41:10 2017 -0700

----------------------------------------------------------------------
 src/master/master.cpp | 40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8054de19/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 72b7de4..a5376f9 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -6165,15 +6165,10 @@ void Master::___reregisterSlave(
   CHECK_NOTNULL(slave);
 
   // Send the latest framework pids to the slave.
-  hashset<FrameworkID> ids;
-
   foreach (const FrameworkInfo& frameworkInfo, frameworks) {
     CHECK(frameworkInfo.has_id());
-    ids.insert(frameworkInfo.id());
-  }
+    Framework* framework = getFramework(frameworkInfo.id());
 
-  foreach (const FrameworkID& frameworkId, ids) {
-    Framework* framework = getFramework(frameworkId);
     if (framework != nullptr) {
       UpdateFrameworkMessage message;
       message.mutable_framework_id()->CopyFrom(framework->id());
@@ -6185,25 +6180,24 @@ void Master::___reregisterSlave(
       message.set_pid(framework->pid.getOrElse(UPID()));
 
       send(slave->pid, message);
-    }
-  }
-
-  // If the agent is running any frameworks the master doesn't know
-  // about, recover the framework using the `FrameworkInfo` supplied
-  // by the agent. We don't recover frameworks that have already
-  // completed at the master.
-  foreach (const FrameworkInfo& frameworkInfo, frameworks) {
-    if (getFramework(frameworkInfo.id()) != nullptr) {
-      continue;
-    }
-    if (isCompletedFramework(frameworkInfo.id())) {
-      continue;
-    }
+    } else {
+      // The agent is running a framework that the master doesn't know
+      // about. Recover the framework using the `FrameworkInfo`
+      // supplied by the agent.
+
+      // We skip recovering the framework if it has already been
+      // marked completed at the master. In this situation, the master
+      // has already told the agent to shutdown the framework in
+      // `__reregisterSlave`.
+      if (isCompletedFramework(frameworkInfo.id())) {
+        continue;
+      }
 
-    LOG(INFO) << "Recovering framework " << frameworkInfo.id()
-              << " from re-registering agent " << *slave;
+      LOG(INFO) << "Recovering framework " << frameworkInfo.id()
+                << " from re-registering agent " << *slave;
 
-    recoverFramework(frameworkInfo);
+      recoverFramework(frameworkInfo);
+    }
   }
 
   LOG(INFO) << "Sending updated checkpointed resources "