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:23 UTC
[07/12] mesos git commit: Moved Docker command check code inside
health check library.
Moved Docker command check code inside health check library.
Now with the health check library refactor, the wrapping of `docker
exec` for the Docker command health checks can be easily moved inside
the library.
Review: https://reviews.apache.org/r/65396/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ab738971
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ab738971
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ab738971
Branch: refs/heads/master
Commit: ab73897161e809c5bdc165617cded853bc7e9d91
Parents: 36aa2d5
Author: Akash Gupta <ak...@hotmail.com>
Authored: Sat Feb 24 12:10:00 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Sun Feb 25 22:13:32 2018 -0800
----------------------------------------------------------------------
src/checks/checker_process.cpp | 35 ++++++++++++++++++++++++++++++++---
src/docker/executor.cpp | 29 -----------------------------
2 files changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ab738971/src/checks/checker_process.cpp
----------------------------------------------------------------------
diff --git a/src/checks/checker_process.cpp b/src/checks/checker_process.cpp
index 73a6481..d3ab754 100644
--- a/src/checks/checker_process.cpp
+++ b/src/checks/checker_process.cpp
@@ -550,9 +550,38 @@ Future<int> CheckerProcess::dockerCommandCheck(
const check::Command& cmd,
const runtime::Docker& docker)
{
- // TODO(akagup): Stub this method for this patch. Next patch will move the
- // docker exec logic to here.
- return commandCheck(cmd, runtime::Plain{docker.namespaces, docker.taskPid});
+ // Wrap the original health check command in `docker exec`.
+ const CommandInfo& command = cmd.info;
+
+ vector<string> commandArguments;
+ commandArguments.push_back(docker.dockerPath);
+ commandArguments.push_back("-H");
+ commandArguments.push_back(docker.socketName);
+ commandArguments.push_back("exec");
+ commandArguments.push_back(docker.containerName);
+
+ if (command.shell()) {
+ commandArguments.push_back("sh");
+ commandArguments.push_back("-c");
+ commandArguments.push_back("\"");
+ commandArguments.push_back(command.value());
+ commandArguments.push_back("\"");
+ } else {
+ commandArguments.push_back(command.value());
+
+ foreach (const string& argument, command.arguments()) {
+ commandArguments.push_back(argument);
+ }
+ }
+
+ CommandInfo dockerCmd(command);
+ dockerCmd.set_shell(true);
+ dockerCmd.clear_arguments();
+ dockerCmd.set_value(strings::join(" ", commandArguments));
+
+ return commandCheck(
+ check::Command(dockerCmd),
+ runtime::Plain{docker.namespaces, docker.taskPid});
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/ab738971/src/docker/executor.cpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.cpp b/src/docker/executor.cpp
index aaa56f2..b774b9e 100644
--- a/src/docker/executor.cpp
+++ b/src/docker/executor.cpp
@@ -675,35 +675,6 @@ private:
<< validateVersion.error();
return;
}
-
- // Wrap the original health check command in `docker exec`.
- const CommandInfo& command = healthCheck.command();
-
- vector<string> commandArguments;
- commandArguments.push_back(docker->getPath());
- commandArguments.push_back("-H");
- commandArguments.push_back(docker->getSocket());
- commandArguments.push_back("exec");
- commandArguments.push_back(containerName);
-
- if (command.shell()) {
- commandArguments.push_back("sh");
- commandArguments.push_back("-c");
- commandArguments.push_back("\"");
- commandArguments.push_back(command.value());
- commandArguments.push_back("\"");
- } else {
- commandArguments.push_back(command.value());
-
- foreach (const string& argument, command.arguments()) {
- commandArguments.push_back(argument);
- }
- }
-
- healthCheck.mutable_command()->set_shell(true);
- healthCheck.mutable_command()->clear_arguments();
- healthCheck.mutable_command()->set_value(
- strings::join(" ", commandArguments));
}
vector<string> namespaces;