You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/07/04 17:01:34 UTC

[13/15] mesos git commit: Explicitly passed in launcher dir to command executor.

Explicitly passed in launcher dir to command executor.

Relying on dirname is not quite reliable, especially in tests where
launchable scripts are under 'build/src', but actual binaries are
under 'build/src/.libs'. This patch passed in launcher_dir explicitly
through executor flags.

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


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

Branch: refs/heads/master
Commit: 293d9eaa9c008af426df47bed3b29ecda8f70a72
Parents: 40ec907
Author: Jie Yu <yu...@gmail.com>
Authored: Fri Jul 1 16:40:32 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Jul 4 10:01:13 2016 -0700

----------------------------------------------------------------------
 src/launcher/executor.cpp        | 14 +++++++-------
 src/slave/slave.cpp              |  2 ++
 src/tests/health_check_tests.cpp |  8 --------
 src/tests/slave_tests.cpp        |  2 +-
 4 files changed, 10 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/293d9eaa/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index f78f0bf..78c4182 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -787,6 +787,11 @@ public:
         "If specified, this is the overrided command for launching the\n"
         "task (instead of the command from TaskInfo).");
 
+    add(&launcher_dir,
+        "launcher_dir",
+        "Directory path of Mesos binaries.",
+        PKGLIBEXECDIR);
+
     // TODO(nnielsen): Add 'prefix' option to enable replacing
     // 'sh -c' with user specified wrapper.
   }
@@ -796,6 +801,7 @@ public:
   Option<string> working_directory;
   Option<string> user;
   Option<string> task_command;
+  string launcher_dir;
 };
 
 
@@ -827,12 +833,6 @@ int main(int argc, char** argv)
     LOG(WARNING) << warning.message;
   }
 
-  const Option<string> envPath = os::getenv("MESOS_LAUNCHER_DIR");
-
-  string path = envPath.isSome()
-    ? envPath.get()
-    : os::realpath(Path(argv[0]).dirname()).get();
-
   Option<string> value = os::getenv("MESOS_FRAMEWORK_ID");
   if (value.isNone()) {
     EXIT(EXIT_FAILURE)
@@ -868,7 +868,7 @@ int main(int argc, char** argv)
 
   Owned<mesos::v1::internal::CommandExecutor> executor(
       new mesos::v1::internal::CommandExecutor(
-          path,
+          flags.launcher_dir,
           flags.rootfs,
           flags.sandbox_directory,
           flags.working_directory,

http://git-wip-us.apache.org/repos/asf/mesos/blob/293d9eaa/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 6857c87..de4cb5a 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -3956,6 +3956,8 @@ ExecutorInfo Slave::getExecutorInfo(
       executor.mutable_command()->set_shell(false);
       executor.mutable_command()->set_value(path.get());
       executor.mutable_command()->add_arguments("mesos-executor");
+      executor.mutable_command()->add_arguments(
+          "--launcher_dir=" + flags.launcher_dir);
 
       if (hasRootfs) {
         executor.mutable_command()->add_arguments(

http://git-wip-us.apache.org/repos/asf/mesos/blob/293d9eaa/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index 3e8e41b..47c35d1 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -118,14 +118,6 @@ public:
     CommandInfo command;
     command.set_value(cmd);
 
-    Environment::Variable* variable =
-      command.mutable_environment()->add_variables();
-
-    // We need to set the correct directory to launch health check process
-    // instead of the default for tests.
-    variable->set_name("MESOS_LAUNCHER_DIR");
-    variable->set_value(getLauncherDir());
-
     task.mutable_command()->CopyFrom(command);
 
     if (containerInfo.isSome()) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/293d9eaa/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 868e521..60f9e16 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -544,7 +544,7 @@ TEST_F(SlaveTest, GetExecutorInfo)
   // Now assert that it actually is running mesos-executor without any
   // bleedover from the command we intend on running.
   EXPECT_FALSE(executor.command().shell());
-  EXPECT_EQ(1, executor.command().arguments_size());
+  EXPECT_EQ(2, executor.command().arguments_size());
   ASSERT_TRUE(executor.has_labels());
   EXPECT_EQ(2, executor.labels().labels_size());
   ASSERT_TRUE(executor.has_discovery());