You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2018/02/26 07:24:25 UTC
[09/12] mesos git commit: Fixed quoting bug in Docker executor
command checks.
Fixed quoting bug in Docker executor command checks.
The docker executor was wrapping the `docker exec` command with
`sh -c ""`, which was causing problems due to quoting, especially on
Windows. Now, the command health check simply runs `docker exec`
without any wrapping.
Review: https://reviews.apache.org/r/65419/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3b6d58cf
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3b6d58cf
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3b6d58cf
Branch: refs/heads/master
Commit: 3b6d58cfb6e61766a4d1a55b2a6b2c475f5d1c57
Parents: ab73897
Author: Akash Gupta <ak...@hotmail.com>
Authored: Sat Feb 24 12:10:11 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Sun Feb 25 22:13:32 2018 -0800
----------------------------------------------------------------------
src/checks/checker_process.cpp | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3b6d58cf/src/checks/checker_process.cpp
----------------------------------------------------------------------
diff --git a/src/checks/checker_process.cpp b/src/checks/checker_process.cpp
index d3ab754..1e696ad 100644
--- a/src/checks/checker_process.cpp
+++ b/src/checks/checker_process.cpp
@@ -563,21 +563,33 @@ Future<int> CheckerProcess::dockerCommandCheck(
if (command.shell()) {
commandArguments.push_back("sh");
commandArguments.push_back("-c");
- commandArguments.push_back("\"");
+
+ // We don't need to quote the arguments, because we're converting the
+ // shell command to the executable form.
commandArguments.push_back(command.value());
- commandArguments.push_back("\"");
} else {
- commandArguments.push_back(command.value());
-
- foreach (const string& argument, command.arguments()) {
- commandArguments.push_back(argument);
+ // The format is `docker exec [OPTIONS] CONTAINER COMMAND [ARG...]`, so we
+ // have `COMMAND == command.value()` or `COMMAND == command.arguments()[0]`.
+ // So, `command.arguments()[0]` can either be executable name or the "real"
+ // first argument to the program (`argv[1]`). This matches the logic in
+ // `docker->run`.
+ if (command.has_value()) {
+ commandArguments.push_back(command.value());
}
+
+ commandArguments.insert(
+ commandArguments.end(),
+ command.arguments().cbegin(),
+ command.arguments().cend());
}
CommandInfo dockerCmd(command);
- dockerCmd.set_shell(true);
+ dockerCmd.set_shell(false);
+ dockerCmd.set_value(commandArguments[0]);
dockerCmd.clear_arguments();
- dockerCmd.set_value(strings::join(" ", commandArguments));
+ foreach (const string& argument, commandArguments) {
+ dockerCmd.add_arguments(argument);
+ }
return commandCheck(
check::Command(dockerCmd),