You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2015/04/21 00:32:02 UTC

[2/6] mesos git commit: Enabled environment decorator to override.

Enabled environment decorator to override.

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


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

Branch: refs/heads/master
Commit: a454fc50a8304453d436021ff36742a6af6d8798
Parents: a090e9d
Author: Niklas Nielsen <ni...@qni.dk>
Authored: Mon Apr 20 14:36:28 2015 -0700
Committer: Adam B <ad...@mesosphere.io>
Committed: Mon Apr 20 14:36:28 2015 -0700

----------------------------------------------------------------------
 src/examples/test_hook_module.cpp | 5 +++++
 src/hook/manager.cpp              | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a454fc50/src/examples/test_hook_module.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_hook_module.cpp b/src/examples/test_hook_module.cpp
index 4fc7013..64fb503 100644
--- a/src/examples/test_hook_module.cpp
+++ b/src/examples/test_hook_module.cpp
@@ -71,6 +71,11 @@ public:
     LOG(INFO) << "Executing 'slaveExecutorEnvironmentDecorator' hook";
 
     Environment environment;
+
+    if (executorInfo.command().has_environment()) {
+      environment.CopyFrom(executorInfo.command().environment());
+    }
+
     Environment::Variable* variable = environment.add_variables();
     variable->set_name("FOO");
     variable->set_value("bar");

http://git-wip-us.apache.org/repos/asf/mesos/blob/a454fc50/src/hook/manager.cpp
----------------------------------------------------------------------
diff --git a/src/hook/manager.cpp b/src/hook/manager.cpp
index 0d79ba2..28d5c58 100644
--- a/src/hook/manager.cpp
+++ b/src/hook/manager.cpp
@@ -128,11 +128,11 @@ Environment HookManager::slaveExecutorEnvironmentDecorator(
   foreachpair (const string& name, Hook* hook, availableHooks) {
     const Result<Environment>& result =
       hook->slaveExecutorEnvironmentDecorator(executorInfo);
+
+    // NOTE: If the hook returns None(), the environment won't be
+    // changed.
     if (result.isSome()) {
-      // Update executorInfo to include newer environment variables
-      // so that the next hook module can extend the environment
-      // variables instead of simply overwriting them.
-      executorInfo.mutable_command()->mutable_environment()->MergeFrom(
+      executorInfo.mutable_command()->mutable_environment()->CopyFrom(
           result.get());
     } else if (result.isError()) {
       LOG(WARNING) << "Slave environment decorator hook failed for module '"