Supported `ContainerLogger` with nested containers.

For nested containers, the sandbox directory still exists.  However,
ExecutorInfo's no longer map directly one-to-one to containers.
That means a nested container does not have an associated ExecutorInfo.

The `ExecutorInfo` parameter provides metadata for the `ContainerLogger`
including the FrameworkID, ExecutorID, environment variables, and
arbitrary Labels.  For nested containers, the top-level parent's
`ExecutorInfo` should be sufficient to provide the same metadata.

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


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

Branch: refs/heads/master
Commit: 1e514ca023526f949e0ed5b91d43636a1b2fd172
Parents: 9588a60
Author: Gilbert Song <songzihao1...@gmail.com>
Authored: Wed Oct 12 14:38:43 2016 -0700
Committer: Joseph Wu <josep...@apache.org>
Committed: Wed Oct 12 14:41:30 2016 -0700

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1e514ca0/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp 
b/src/slave/containerizer/mesos/containerizer.cpp
index 7ec6f78..f5a4858 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1333,8 +1333,27 @@ Future<bool> MesosContainerizerProcess::_launch(
     environment.values[name] = value;
   }
 
+  // Determine the 'ExecutorInfo' for the logger. If launching a
+  // top level executor container, use the 'ExecutorInfo' from
+  // 'ContainerConfig'. If launching a nested container, use the
+  // 'ExecutorInfo' from its top level parent container.
+  ExecutorInfo executorInfo;
+  if (container->config.has_executor_info()) {
+    // The top level executor container case. The 'ExecutorInfo'
+    // will always be set in 'ContainerConfig'.
+    executorInfo = container->config.executor_info();
+  } else {
+    // The nested container case. Use the 'ExecutorInfo' from its root
+    // parent container.
+    CHECK(containerId.has_parent());
+    const ContainerID& rootContainerId = getRootContainerId(containerId);
+    CHECK(containers_.contains(rootContainerId));
+    CHECK(containers_[rootContainerId]->config.has_executor_info());
+    executorInfo = containers_[rootContainerId]->config.executor_info();
+  }
+
   return logger->prepare(
-      container->config.executor_info(),
+      executorInfo,
       container->config.directory())
     .then(defer(
         self(),

Reply via email to