Repository: mesos Updated Branches: refs/heads/master e469815db -> 788d3a617
Renamed argv in CommandInfo to arguments. Review: https://reviews.apache.org/r/24672 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/788d3a61 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/788d3a61 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/788d3a61 Branch: refs/heads/master Commit: 788d3a61754951d0c49e2ce085aa8ed0b79167e6 Parents: e469815 Author: Jie Yu <[email protected]> Authored: Wed Aug 13 14:33:50 2014 -0700 Committer: Jie Yu <[email protected]> Committed: Wed Aug 13 15:13:06 2014 -0700 ---------------------------------------------------------------------- include/mesos/mesos.proto | 26 ++++++++++++++------------ src/common/type_utils.cpp | 6 +++--- src/health-check/main.cpp | 2 +- src/launcher/executor.cpp | 10 +++++----- src/slave/containerizer/mesos/launch.cpp | 8 ++++---- src/slave/http.cpp | 2 +- src/slave/slave.cpp | 2 +- src/tests/health_check_tests.cpp | 2 +- 8 files changed, 30 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/include/mesos/mesos.proto ---------------------------------------------------------------------- diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto index dc781d1..adc8fab 100644 --- a/include/mesos/mesos.proto +++ b/include/mesos/mesos.proto @@ -231,20 +231,22 @@ message CommandInfo { optional Environment environment = 2; - // Whether the command will be executed via shell (i.e., /bin/sh -c) - // or not. If it is set to true, the 'value' below will be used as - // the shell command. Otherwise, the command will be executed via - // execve using the specified 'argv' below. - optional bool shell = 6 [default = true]; - - // The shell command (i.e., 'echo hello world'). - // NOTE: This field is changed from 'required' to 'optional' in - // 0.20.0. It will only cause issues if a new framework is + // There are two ways to specify the command: + // 1) If 'shell == true', the command will be launched via shell + // (i.e., /bin/sh -c 'value'). The 'value' specified will be + // treated as the shell command. The 'arguments' will be ignored. + // 2) If 'shell == false', the command will be launched by passing + // arguments to an executable. The 'value' specified will be + // treated as the filename of the executable. The 'arguments' + // will be treated as the arguments to the executable. This is + // similar to how POSIX exec families launch processes (i.e., + // execlp(value, arguments(0), arguments(1), ...)). + // NOTE: The field 'value' is changed from 'required' to 'optional' + // in 0.20.0. It will only cause issues if a new framework is // connecting to an old master. + optional bool shell = 6 [default = true]; optional string value = 3; - - // The argument list. - repeated string argv = 7; + repeated string arguments = 7; // Enables executor and tasks to run as a specific user. If the user // field is present both in FrameworkInfo and here, the CommandInfo http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/src/common/type_utils.cpp ---------------------------------------------------------------------- diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp index 78bfa94..e55b1f9 100644 --- a/src/common/type_utils.cpp +++ b/src/common/type_utils.cpp @@ -69,13 +69,13 @@ bool operator == (const CommandInfo& left, const CommandInfo& right) } } - if (left.argv().size() != right.argv().size()) { + if (left.arguments().size() != right.arguments().size()) { return false; } // The order of argv is important. - for (int i = 0; i < left.argv().size(); i++) { - if (left.argv().Get(i) != right.argv().Get(i)) { + for (int i = 0; i < left.arguments().size(); i++) { + if (left.arguments().Get(i) != right.arguments().Get(i)) { return false; } } http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/src/health-check/main.cpp ---------------------------------------------------------------------- diff --git a/src/health-check/main.cpp b/src/health-check/main.cpp index 6849947..730a7a2 100644 --- a/src/health-check/main.cpp +++ b/src/health-check/main.cpp @@ -183,7 +183,7 @@ private: } vector<string> argv; - foreach (const string& arg, command.argv()) { + foreach (const string& arg, command.arguments()) { argv.push_back(arg); } http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/src/launcher/executor.cpp ---------------------------------------------------------------------- diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp index 64a4175..9b767a5 100644 --- a/src/launcher/executor.cpp +++ b/src/launcher/executor.cpp @@ -163,11 +163,11 @@ public: } // Prepare the argv before fork as it's not async signal safe. - char **argv = new char*[task.command().argv_size() + 1]; - for (int i = 0; i < task.command().argv_size(); i++) { - argv[i] = (char*) task.command().argv(i).c_str(); + char **argv = new char*[task.command().arguments().size() + 1]; + for (int i = 0; i < task.command().arguments().size(); i++) { + argv[i] = (char*) task.command().arguments(i).c_str(); } - argv[task.command().argv_size()] = NULL; + argv[task.command().arguments().size()] = NULL; // Prepare the messages before fork as it's not async signal safe. string command; @@ -176,7 +176,7 @@ public: } else { command = "[" + task.command().value() + ", " + - strings::join(", ", task.command().argv()) + "]"; + strings::join(", ", task.command().arguments()) + "]"; } if ((pid = fork()) == -1) { http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/src/slave/containerizer/mesos/launch.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/launch.cpp b/src/slave/containerizer/mesos/launch.cpp index 4e727a1..35b57b3 100644 --- a/src/slave/containerizer/mesos/launch.cpp +++ b/src/slave/containerizer/mesos/launch.cpp @@ -233,11 +233,11 @@ int MesosContainerizerLaunch::execute() envp()); } else { // Use execve to launch the command. - char** argv = new char*[command.get().argv_size() + 1]; - for (int i = 0; i < command.get().argv_size(); i++) { - argv[i] = strdup(command.get().argv(i).c_str()); + char** argv = new char*[command.get().arguments().size() + 1]; + for (int i = 0; i < command.get().arguments().size(); i++) { + argv[i] = strdup(command.get().arguments(i).c_str()); } - argv[command.get().argv_size()] = NULL; + argv[command.get().arguments().size()] = NULL; execve(command.get().value().c_str(), argv, envp()); } http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/src/slave/http.cpp ---------------------------------------------------------------------- diff --git a/src/slave/http.cpp b/src/slave/http.cpp index 92eb348..9ef0a1f 100644 --- a/src/slave/http.cpp +++ b/src/slave/http.cpp @@ -93,7 +93,7 @@ JSON::Object model(const CommandInfo& command) } JSON::Array argv; - foreach (const string& arg, command.argv()) { + foreach (const string& arg, command.arguments()) { argv.values.push_back(arg); } object.values["argv"] = argv; http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index 59477d5..1eaab04 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -2410,7 +2410,7 @@ ExecutorInfo Slave::getExecutorInfo( } else { string args = task.command().value() + ", " + - strings::join(", ", task.command().argv()); + strings::join(", ", task.command().arguments()); if (args.length() > 15) { name += "(Command: [" + args.substr(0, 12) + "...])"; http://git-wip-us.apache.org/repos/asf/mesos/blob/788d3a61/src/tests/health_check_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp index 64fbf62..b6d7fa8 100644 --- a/src/tests/health_check_tests.cpp +++ b/src/tests/health_check_tests.cpp @@ -231,7 +231,7 @@ TEST_F(HealthCheckTest, HealthyTaskNonShell) CommandInfo command; command.set_shell(false); command.set_value("/bin/true"); - command.add_argv("true"); + command.add_arguments("true"); vector<TaskInfo> tasks = populateTasks("sleep 120", command, offers.get()[0]);
