You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/02/08 01:40:52 UTC

[6/6] mesos git commit: Updated AppC & Docker runtime isolators' handling of Environment.

Updated AppC & Docker runtime isolators' handling of Environment.

This commit builds upon the command executor's new `--task_environment`
flag, which allows isolators to specify environment variables meant
for the task, without affecting the executor's environment.

This is important as the command executor is both an executor and
a task.  Some environment variables from isolators are intended
for the executor, while others are intended for the task (such as
from the two runtime isolators).

For example, a container image may provide an environment variable
like `LD_LIBRARY_PATH=/image/specific/location`, whereas the default
executor expects to find libraries in the host's environment.  If the
image's environment end up in the command executor at launch time,
the command executor may simply fail to launch.

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


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

Branch: refs/heads/master
Commit: f3518daa9dca03dbdb59b092d23ebe1356f352d4
Parents: 0370ca6
Author: Joseph Wu <jo...@apache.org>
Authored: Tue Feb 7 14:10:48 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Feb 7 17:35:23 2017 -0800

----------------------------------------------------------------------
 .../containerizer/mesos/isolators/appc/runtime.cpp    | 14 ++++++++++----
 .../containerizer/mesos/isolators/docker/runtime.cpp  | 14 ++++++++++----
 2 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f3518daa/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/appc/runtime.cpp b/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
index 9bc3fd8..ffaec5a 100644
--- a/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
+++ b/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
@@ -103,10 +103,6 @@ Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
   // Set 'launchInfo'.
   ContainerLaunchInfo launchInfo;
 
-  if (environment.isSome()) {
-    launchInfo.mutable_environment()->CopyFrom(environment.get());
-  }
-
   // If working directory or command exists, operation has to be
   // handled specially for the command task. For the command task,
   // the working directory and task command will be passed to
@@ -119,6 +115,12 @@ Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
     // command with value as 'mesos-executor'.
     CommandInfo executorCommand = containerConfig.executor_info().command();
 
+    if (environment.isSome()) {
+      executorCommand.add_arguments(
+          "--task_environment=" +
+          stringify(JSON::protobuf(environment.get())));
+    }
+
     // Pass working directory to command executor as a flag.
     if (workingDirectory.isSome()) {
       executorCommand.add_arguments(
@@ -136,6 +138,10 @@ Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
     launchInfo.mutable_command()->CopyFrom(executorCommand);
   } else {
     // The custom executor, default executor and nested container cases.
+    if (environment.isSome()) {
+      launchInfo.mutable_environment()->CopyFrom(environment.get());
+    }
+
     if (workingDirectory.isSome()) {
       launchInfo.set_working_directory(workingDirectory.get());
     }

http://git-wip-us.apache.org/repos/asf/mesos/blob/f3518daa/src/slave/containerizer/mesos/isolators/docker/runtime.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/docker/runtime.cpp b/src/slave/containerizer/mesos/isolators/docker/runtime.cpp
index 2d816e5..08350e6 100644
--- a/src/slave/containerizer/mesos/isolators/docker/runtime.cpp
+++ b/src/slave/containerizer/mesos/isolators/docker/runtime.cpp
@@ -123,10 +123,6 @@ Future<Option<ContainerLaunchInfo>> DockerRuntimeIsolatorProcess::prepare(
   // Set 'launchInfo'.
   ContainerLaunchInfo launchInfo;
 
-  if (environment.isSome()) {
-    launchInfo.mutable_environment()->CopyFrom(environment.get());
-  }
-
   // If working directory or command exists, operation has to be
   // handled specially for the command task. For the command task,
   // the working directory and task command will be passed to
@@ -139,6 +135,12 @@ Future<Option<ContainerLaunchInfo>> DockerRuntimeIsolatorProcess::prepare(
     // command with value as 'mesos-executor'.
     CommandInfo executorCommand = containerConfig.executor_info().command();
 
+    if (environment.isSome()) {
+      executorCommand.add_arguments(
+          "--task_environment=" +
+          stringify(JSON::protobuf(environment.get())));
+    }
+
     // Pass working directory to command executor as a flag.
     if (workingDirectory.isSome()) {
       executorCommand.add_arguments(
@@ -156,6 +158,10 @@ Future<Option<ContainerLaunchInfo>> DockerRuntimeIsolatorProcess::prepare(
     launchInfo.mutable_command()->CopyFrom(executorCommand);
   } else {
     // The custom executor, default executor and nested container cases.
+    if (environment.isSome()) {
+      launchInfo.mutable_environment()->CopyFrom(environment.get());
+    }
+
     if (workingDirectory.isSome()) {
       launchInfo.set_working_directory(workingDirectory.get());
     }