Repository: mesos
Updated Branches:
  refs/heads/master 020b37ee9 -> 209f8e7fd


Fixed fetcher to not pick up environment variables it should not see.

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


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

Branch: refs/heads/master
Commit: 916a43e2cb2cb1c26889fa3ce86633718789d274
Parents: 020b37e
Author: Till Toenshoff <[email protected]>
Authored: Thu Feb 23 01:53:42 2017 +0100
Committer: Till Toenshoff <[email protected]>
Committed: Thu Feb 23 01:53:42 2017 +0100

----------------------------------------------------------------------
 src/slave/containerizer/fetcher.cpp | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/916a43e2/src/slave/containerizer/fetcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/fetcher.cpp 
b/src/slave/containerizer/fetcher.cpp
index 9ec38dc..34a5fbb 100644
--- a/src/slave/containerizer/fetcher.cpp
+++ b/src/slave/containerizer/fetcher.cpp
@@ -22,8 +22,10 @@
 #include <process/dispatch.hpp>
 #include <process/owned.hpp>
 
+#include <stout/hashset.hpp>
 #include <stout/net.hpp>
 #include <stout/path.hpp>
+#include <stout/strings.hpp>
 #ifdef __WINDOWS__
 #include <stout/windows.hpp>
 #endif // __WINDOWS__
@@ -45,6 +47,8 @@ using std::string;
 using std::transform;
 using std::vector;
 
+using strings::startsWith;
+
 using mesos::fetcher::FetcherInfo;
 
 using process::async;
@@ -822,12 +826,27 @@ Future<Nothing> FetcherProcess::run(
 
   // We pass arguments to the fetcher program by means of an
   // environment variable.
-  map<string, string> environment = os::environment();
-
-  // The libprocess port is explicitly removed because this will conflict
-  // with the already-running agent.
-  environment.erase("LIBPROCESS_PORT");
-  environment.erase("LIBPROCESS_ADVERTISE_PORT");
+  // For assuring that we pass on variables that may be consumed by
+  // the mesos-fetcher, we whitelist them before masking out any
+  // unwanted agent->fetcher environment spillover.
+  // TODO(tillt): Consider using the `mesos::internal::logging::Flags`
+  // to determine the whitelist.
+  const hashset<string> whitelist = {
+    "MESOS_EXTERNAL_LOG_FILE",
+    "MESOS_INITIALIZE_DRIVER_LOGGING",
+    "MESOS_LOG_DIR",
+    "MESOS_LOGBUFSECS",
+    "MESOS_LOGGING_LEVEL",
+    "MESOS_QUIET"
+  };
+
+  map<string, string> environment;
+  foreachpair (const string& key, const string& value, os::environment()) {
+    if (whitelist.contains(strings::upper(key)) ||
+        (!startsWith(key, "LIBPROCESS_") && !startsWith(key, "MESOS_"))) {
+      environment.emplace(key, value);
+    }
+  }
 
   environment["MESOS_FETCHER_INFO"] = stringify(JSON::protobuf(info));
 

Reply via email to