You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ti...@apache.org on 2017/05/08 17:24:35 UTC

[1/3] mesos git commit: Added new ContainerLaunchInfo task_environment.

Repository: mesos
Updated Branches:
  refs/heads/master 851d5f0a1 -> b53c5d3a5


Added new ContainerLaunchInfo task_environment.

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


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

Branch: refs/heads/master
Commit: c3130bd56d6a691da8c561e7acc739fe5fd87564
Parents: 851d5f0
Author: Till Toenshoff <to...@me.com>
Authored: Mon May 8 19:15:29 2017 +0200
Committer: Till Toenshoff <to...@me.com>
Committed: Mon May 8 19:15:29 2017 +0200

----------------------------------------------------------------------
 include/mesos/slave/containerizer.proto | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c3130bd5/include/mesos/slave/containerizer.proto
----------------------------------------------------------------------
diff --git a/include/mesos/slave/containerizer.proto b/include/mesos/slave/containerizer.proto
index c30b1fc..41f2905 100644
--- a/include/mesos/slave/containerizer.proto
+++ b/include/mesos/slave/containerizer.proto
@@ -161,6 +161,8 @@ message ContainerLaunchInfo {
   // The additional preparation commands to execute before
   // executing the command.
   repeated CommandInfo pre_exec_commands = 1;
+
+  // The environment set for the container.
   optional Environment environment = 2;
 
   // (Linux only) The root filesystem for the container.
@@ -196,6 +198,12 @@ message ContainerLaunchInfo {
 
   // (POSIX only) The slave path of the pseudo terminal.
   optional string tty_slave_path = 14;
+
+  // The environment specific for command tasks. Gets merged with
+  // 'environment' and the 'command' `Environment`.
+  // TODO(tillt): Remove this once we no longer support the old style
+  // command task (i.e., that uses mesos-execute).
+  optional Environment task_environment = 15;
 }
 
 


[3/3] mesos git commit: Updated runtime isolators to use new task_environment member.

Posted by ti...@apache.org.
Updated runtime isolators to use new task_environment member.

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


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

Branch: refs/heads/master
Commit: b53c5d3a598f0b7bf6fa7eda1f35dee0db00e082
Parents: 1973ab5
Author: Till Toenshoff <to...@me.com>
Authored: Mon May 8 19:16:54 2017 +0200
Committer: Till Toenshoff <to...@me.com>
Committed: Mon May 8 19:16:54 2017 +0200

----------------------------------------------------------------------
 src/slave/containerizer/mesos/isolators/appc/runtime.cpp   | 4 +---
 src/slave/containerizer/mesos/isolators/docker/runtime.cpp | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b53c5d3a/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 ffaec5a..f76b22b 100644
--- a/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
+++ b/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
@@ -116,9 +116,7 @@ Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
     CommandInfo executorCommand = containerConfig.executor_info().command();
 
     if (environment.isSome()) {
-      executorCommand.add_arguments(
-          "--task_environment=" +
-          stringify(JSON::protobuf(environment.get())));
+      launchInfo.mutable_task_environment()->CopyFrom(environment.get());
     }
 
     // Pass working directory to command executor as a flag.

http://git-wip-us.apache.org/repos/asf/mesos/blob/b53c5d3a/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 08350e6..2a6e0b1 100644
--- a/src/slave/containerizer/mesos/isolators/docker/runtime.cpp
+++ b/src/slave/containerizer/mesos/isolators/docker/runtime.cpp
@@ -136,9 +136,7 @@ Future<Option<ContainerLaunchInfo>> DockerRuntimeIsolatorProcess::prepare(
     CommandInfo executorCommand = containerConfig.executor_info().command();
 
     if (environment.isSome()) {
-      executorCommand.add_arguments(
-          "--task_environment=" +
-          stringify(JSON::protobuf(environment.get())));
+      launchInfo.mutable_task_environment()->CopyFrom(environment.get());
     }
 
     // Pass working directory to command executor as a flag.


[2/3] mesos git commit: Updated containerizer for isolator task_environment merge.

Posted by ti...@apache.org.
Updated containerizer for isolator task_environment merge.

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


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

Branch: refs/heads/master
Commit: 1973ab59f731cb7c44c2abfc851567f3b9e6555a
Parents: c3130bd
Author: Till Toenshoff <to...@me.com>
Authored: Mon May 8 19:15:57 2017 +0200
Committer: Till Toenshoff <to...@me.com>
Committed: Mon May 8 19:15:57 2017 +0200

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/1973ab59/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index b58baed..58ab745 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1347,6 +1347,32 @@ Future<bool> MesosContainerizerProcess::_launch(
     launchInfo.mutable_command()->CopyFrom(container->config.command_info());
   }
 
+  // For command tasks specifically, we should add the task_environment
+  // flag to the launch command of the command executor.
+  // TODO(tillt): Remove this once we no longer support the old style
+  // command task (i.e., that uses mesos-execute).
+  if (container->config.has_task_info() && launchInfo.has_task_environment()) {
+    hashmap<string, string> commandTaskEnvironment;
+
+    foreach (const Environment::Variable& variable,
+             launchInfo.task_environment().variables()) {
+      const string& name = variable.name();
+      const string& value = variable.value();
+      if (commandTaskEnvironment.contains(name) &&
+          commandTaskEnvironment[name] != value) {
+        LOG(WARNING) << "Overwriting environment variable '" << name << "' "
+                     << "for container " << containerId;
+      }
+      // TODO(tillt): Consider making this 'secret' aware.
+      commandTaskEnvironment[name] = value;
+    }
+
+    if (!commandTaskEnvironment.empty()) {
+      launchInfo.mutable_command()->add_arguments(
+          "--task_environment=" + string(jsonify(commandTaskEnvironment)));
+    }
+  }
+
   // For the command executor case, we should add the rootfs flag to
   // the launch command of the command executor.
   // TODO(jieyu): Remove this once we no longer support the old style