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 2017/05/09 21:05:43 UTC

mesos git commit: Fixed the MULTI_ROLE upgrade path for an old master and new agent.

Repository: mesos
Updated Branches:
  refs/heads/master c0ff3f268 -> e64c0d88e


Fixed the MULTI_ROLE upgrade path for an old master and new agent.

The agent was accidentally assuming that the task sent by the master
had the `allocation_info` set. The fix is for `getExecutorInfo` to
inject only in the case where it is already set.

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


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

Branch: refs/heads/master
Commit: e64c0d88e0d16a42baa0939e25f0be2dad2c6c52
Parents: c0ff3f2
Author: Benjamin Mahler <bm...@apache.org>
Authored: Mon May 8 18:13:25 2017 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue May 9 14:05:20 2017 -0700

----------------------------------------------------------------------
 src/slave/slave.cpp | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e64c0d88/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index a37c6c8..209aff1 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -4994,21 +4994,28 @@ ExecutorInfo Slave::getExecutorInfo(
       "cpus:" + stringify(DEFAULT_EXECUTOR_CPUS) + ";" +
       "mem:" + stringify(DEFAULT_EXECUTOR_MEM.megabytes())).get();
 
-  // Inject the task's allocation role into the executor's resources.
+  // If the task has an allocation role, we inject it into
+  // the executor as well. Note that old masters will not
+  // ensure the allocation info is set, and the agent will
+  // inject this later, when storing the task/executor.
   Option<string> role = None();
   foreach (const Resource& resource, task.resources()) {
-    CHECK(resource.has_allocation_info());
-
-    if (role.isNone()) {
+    if (role.isNone() && resource.has_allocation_info()) {
       role = resource.allocation_info().role();
     }
 
-    CHECK_EQ(role.get(), resource.allocation_info().role());
-  }
+    // Check that the roles are consistent.
+    Option<string> otherRole = resource.has_allocation_info()
+        ? Option<string>(resource.allocation_info().role()) : None();
 
-  CHECK_SOME(role);
+    CHECK(role == otherRole)
+      << (role.isSome() ? role.get() : "None")
+      << " vs " << (otherRole.isSome() ? otherRole.get() : "None");
+  }
 
-  executorOverhead.allocate(role.get());
+  if (role.isSome()) {
+    executorOverhead.allocate(role.get());
+  }
 
   executor.mutable_resources()->CopyFrom(executorOverhead);