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/02/23 02:42:36 UTC

[2/2] mesos git commit: Fixed fetcher to not pick up environment variables it should not see.

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/42381483
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/42381483
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/42381483

Branch: refs/heads/1.1.x
Commit: 423814831d8bda68cd77ddf84ecfc95439d9fb1a
Parents: 581a491
Author: Till Toenshoff <to...@me.com>
Authored: Thu Feb 23 01:53:42 2017 +0100
Committer: Till Toenshoff <to...@me.com>
Committed: Thu Feb 23 03:42:13 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/42381483/src/slave/containerizer/fetcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/fetcher.cpp b/src/slave/containerizer/fetcher.cpp
index 11104d6..dd62242 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::Future;
@@ -806,12 +810,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));