You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by tn...@apache.org on 2016/04/01 01:48:16 UTC
[1/3] mesos git commit: Fixed indent in docker executor health check
code.
Repository: mesos
Updated Branches:
refs/heads/master ba3ed357c -> 4dcc8635e
Fixed indent in docker executor health check code.
Review: https://reviews.apache.org/r/45555/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b6851df2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b6851df2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b6851df2
Branch: refs/heads/master
Commit: b6851df2a97cae45fd2169eb6adc99e819c64e5e
Parents: ba3ed35
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Thu Mar 31 16:35:12 2016 -0700
Committer: Timothy Chen <tn...@apache.org>
Committed: Thu Mar 31 16:35:18 2016 -0700
----------------------------------------------------------------------
src/docker/executor.cpp | 82 ++++++++++++++++++++++----------------------
1 file changed, 41 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b6851df2/src/docker/executor.cpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.cpp b/src/docker/executor.cpp
index 6dd4838..21453c0 100644
--- a/src/docker/executor.cpp
+++ b/src/docker/executor.cpp
@@ -378,55 +378,55 @@ private:
// Wrap the original health check command in "docker exec".
if (healthCheck.has_command()) {
- CommandInfo command = healthCheck.command();
+ CommandInfo command = healthCheck.command();
- // "docker exec" require docker version greater than 1.3.0.
- Try<Nothing> validateVersion =
- docker->validateVersion(Version(1, 3, 0));
- if (validateVersion.isError()) {
+ // "docker exec" require docker version greater than 1.3.0.
+ Try<Nothing> validateVersion =
+ docker->validateVersion(Version(1, 3, 0));
+ if (validateVersion.isError()) {
+ cerr << "Unable to launch health process: "
+ << validateVersion.error() << endl;
+ return;
+ }
+
+ vector<string> argv;
+ argv.push_back(docker->getPath());
+ argv.push_back("exec");
+ argv.push_back(containerName);
+
+ if (command.shell()) {
+ if (!command.has_value()) {
cerr << "Unable to launch health process: "
- << validateVersion.error() << endl;
+ << "Shell command is not specified." << endl;
return;
}
- vector<string> argv;
- argv.push_back(docker->getPath());
- argv.push_back("exec");
- argv.push_back(containerName);
-
- if (command.shell()) {
- if (!command.has_value()) {
- cerr << "Unable to launch health process: "
- << "Shell command is not specified." << endl;
- return;
- }
-
- argv.push_back("sh");
- argv.push_back("-c");
- argv.push_back("\"");
- argv.push_back(command.value());
- argv.push_back("\"");
- } else {
- if (!command.has_value()) {
- cerr << "Unable to launch health process: "
- << "Executable path is not specified." << endl;
- return;
- }
-
- argv.push_back(command.value());
- foreach (const string& argument, command.arguments()) {
- argv.push_back(argument);
- }
+ argv.push_back("sh");
+ argv.push_back("-c");
+ argv.push_back("\"");
+ argv.push_back(command.value());
+ argv.push_back("\"");
+ } else {
+ if (!command.has_value()) {
+ cerr << "Unable to launch health process: "
+ << "Executable path is not specified." << endl;
+ return;
+ }
+
+ argv.push_back(command.value());
+ foreach (const string& argument, command.arguments()) {
+ argv.push_back(argument);
}
+ }
- command.set_shell(true);
- command.clear_arguments();
- command.set_value(strings::join(" ", argv));
- healthCheck.mutable_command()->CopyFrom(command);
+ command.set_shell(true);
+ command.clear_arguments();
+ command.set_value(strings::join(" ", argv));
+ healthCheck.mutable_command()->CopyFrom(command);
} else {
- cerr << "Unable to launch health process: "
- << "Only command health check is supported now." << endl;
- return;
+ cerr << "Unable to launch health process: "
+ << "Only command health check is supported now." << endl;
+ return;
}
JSON::Object json = JSON::protobuf(healthCheck);
[3/3] mesos git commit: Cleaned up the health check launcher code in
docker executor.
Posted by tn...@apache.org.
Cleaned up the health check launcher code in docker executor.
This change cleans up the code a bit making it easier to read:
- Bail out early wherever possible to reduce nestedness of code
making it easier to read.
- Minor cleanups around merging conditions together wherever
possible.
Review: https://reviews.apache.org/r/45557/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4dcc8635
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4dcc8635
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4dcc8635
Branch: refs/heads/master
Commit: 4dcc8635e612e9a1033170dfbc1e3b562c55927a
Parents: 3b42c0b
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Thu Mar 31 16:35:52 2016 -0700
Committer: Timothy Chen <tn...@apache.org>
Committed: Thu Mar 31 16:35:52 2016 -0700
----------------------------------------------------------------------
src/docker/executor.cpp | 152 +++++++++++++++++++++----------------------
1 file changed, 74 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4dcc8635/src/docker/executor.cpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.cpp b/src/docker/executor.cpp
index a9ed8c2..26cc88d 100644
--- a/src/docker/executor.cpp
+++ b/src/docker/executor.cpp
@@ -373,100 +373,96 @@ private:
void launchHealthCheck(const string& containerName, const TaskInfo& task)
{
- if (!killed && task.has_health_check()) {
- HealthCheck healthCheck = task.health_check();
-
- // Wrap the original health check command in "docker exec".
- if (healthCheck.has_command()) {
- CommandInfo command = healthCheck.command();
-
- // "docker exec" require docker version greater than 1.3.0.
- Try<Nothing> validateVersion =
- docker->validateVersion(Version(1, 3, 0));
-
- if (validateVersion.isError()) {
- cerr << "Unable to launch health process: "
- << validateVersion.error() << endl;
- return;
- }
+ // Bail out early if we have been already killed or if the task has no
+ // associated health checks.
+ if (killed || !task.has_health_check()) {
+ return;
+ }
- vector<string> argv;
- argv.push_back(docker->getPath());
- argv.push_back("exec");
- argv.push_back(containerName);
+ HealthCheck healthCheck = task.health_check();
+ if (!healthCheck.has_command()) {
+ cerr << "Unable to launch health process: "
+ << "Only command health check is supported now" << endl;
+ return;
+ }
- if (command.shell()) {
- if (!command.has_value()) {
- cerr << "Unable to launch health process: "
- << "Shell command is not specified" << endl;
- return;
- }
+ // "docker exec" require docker version greater than 1.3.0.
+ Try<Nothing> validateVersion =
+ docker->validateVersion(Version(1, 3, 0));
- argv.push_back("sh");
- argv.push_back("-c");
- argv.push_back("\"");
- argv.push_back(command.value());
- argv.push_back("\"");
- } else {
- if (!command.has_value()) {
- cerr << "Unable to launch health process: "
- << "Executable path is not specified" << endl;
- return;
- }
+ if (validateVersion.isError()) {
+ cerr << "Unable to launch health process: "
+ << validateVersion.error() << endl;
+ return;
+ }
- argv.push_back(command.value());
+ // Wrap the original health check command in "docker exec".
+ const CommandInfo& command = healthCheck.command();
+ if (!command.has_value()) {
+ cerr << "Unable to launch health process: "
+ << (command.shell() ? "Shell command" : "Executable path")
+ << " is not specified" << endl;
+ return;
+ }
- foreach (const string& argument, command.arguments()) {
- argv.push_back(argument);
- }
- }
+ vector<string> argv;
+ argv.push_back(docker->getPath());
+ argv.push_back("exec");
+ argv.push_back(containerName);
+
+ if (command.shell()) {
+ argv.push_back("sh");
+ argv.push_back("-c");
+ argv.push_back("\"");
+ argv.push_back(command.value());
+ argv.push_back("\"");
+ } else {
+ argv.push_back(command.value());
- command.set_shell(true);
- command.clear_arguments();
- command.set_value(strings::join(" ", argv));
- healthCheck.mutable_command()->CopyFrom(command);
- } else {
- cerr << "Unable to launch health process: "
- << "Only command health check is supported now" << endl;
- return;
+ foreach (const string& argument, command.arguments()) {
+ argv.push_back(argument);
}
+ }
- JSON::Object json = JSON::protobuf(healthCheck);
+ healthCheck.mutable_command()->set_shell(true);
+ healthCheck.mutable_command()->clear_arguments();
+ healthCheck.mutable_command()->set_value(strings::join(" ", argv));
- const string path = path::join(healthCheckDir, "mesos-health-check");
+ JSON::Object json = JSON::protobuf(healthCheck);
- // Launch the subprocess using 'exec' style so that quotes can
- // be properly handled.
- vector<string> argv;
- argv.push_back(path);
- argv.push_back("--executor=" + stringify(self()));
- argv.push_back("--health_check_json=" + stringify(json));
- argv.push_back("--task_id=" + task.task_id().value());
+ const string path = path::join(healthCheckDir, "mesos-health-check");
- const string cmd = strings::join(" ", argv);
+ // Launch the subprocess using 'exec' style so that quotes can
+ // be properly handled.
+ argv.push_back(path);
+ argv.push_back("--executor=" + stringify(self()));
+ argv.push_back("--health_check_json=" + stringify(json));
+ argv.push_back("--task_id=" + task.task_id().value());
- cout << "Launching health check process: " << cmd << endl;
+ const string cmd = strings::join(" ", argv);
- Try<Subprocess> healthProcess =
- process::subprocess(
- path,
- argv,
- // Intentionally not sending STDIN to avoid health check
- // commands that expect STDIN input to block.
- Subprocess::PATH("/dev/null"),
- Subprocess::FD(STDOUT_FILENO),
- Subprocess::FD(STDERR_FILENO));
+ cout << "Launching health check process: " << cmd << endl;
- if (healthProcess.isError()) {
- cerr << "Unable to launch health process: "
- << healthProcess.error() << endl;
- } else {
- healthPid = healthProcess.get().pid();
+ Try<Subprocess> healthProcess =
+ process::subprocess(
+ path,
+ argv,
+ // Intentionally not sending STDIN to avoid health check
+ // commands that expect STDIN input to block.
+ Subprocess::PATH("/dev/null"),
+ Subprocess::FD(STDOUT_FILENO),
+ Subprocess::FD(STDERR_FILENO));
- cout << "Health check process launched at pid: "
- << stringify(healthPid) << endl;
- }
+ if (healthProcess.isError()) {
+ cerr << "Unable to launch health process: "
+ << healthProcess.error() << endl;
+ return;
}
+
+ healthPid = healthProcess.get().pid();
+
+ cout << "Health check process launched at pid: "
+ << stringify(healthPid) << endl;
}
bool killed;
[2/3] mesos git commit: Fixed minor style cleanups to docker health
check code.
Posted by tn...@apache.org.
Fixed minor style cleanups to docker health check code.
Minor cleanups around:
- Remove periods at end of cerr/cout messages.
- Line spacings.
- A few of the `string` variables can be made `const`.
Review: https://reviews.apache.org/r/45556/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3b42c0bb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3b42c0bb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3b42c0bb
Branch: refs/heads/master
Commit: 3b42c0bb057c4651cad0342e3d1507de8caa7769
Parents: b6851df
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Thu Mar 31 16:35:28 2016 -0700
Committer: Timothy Chen <tn...@apache.org>
Committed: Thu Mar 31 16:35:28 2016 -0700
----------------------------------------------------------------------
src/docker/executor.cpp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3b42c0bb/src/docker/executor.cpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.cpp b/src/docker/executor.cpp
index 21453c0..a9ed8c2 100644
--- a/src/docker/executor.cpp
+++ b/src/docker/executor.cpp
@@ -383,6 +383,7 @@ private:
// "docker exec" require docker version greater than 1.3.0.
Try<Nothing> validateVersion =
docker->validateVersion(Version(1, 3, 0));
+
if (validateVersion.isError()) {
cerr << "Unable to launch health process: "
<< validateVersion.error() << endl;
@@ -397,7 +398,7 @@ private:
if (command.shell()) {
if (!command.has_value()) {
cerr << "Unable to launch health process: "
- << "Shell command is not specified." << endl;
+ << "Shell command is not specified" << endl;
return;
}
@@ -409,11 +410,12 @@ private:
} else {
if (!command.has_value()) {
cerr << "Unable to launch health process: "
- << "Executable path is not specified." << endl;
+ << "Executable path is not specified" << endl;
return;
}
argv.push_back(command.value());
+
foreach (const string& argument, command.arguments()) {
argv.push_back(argument);
}
@@ -425,22 +427,24 @@ private:
healthCheck.mutable_command()->CopyFrom(command);
} else {
cerr << "Unable to launch health process: "
- << "Only command health check is supported now." << endl;
+ << "Only command health check is supported now" << endl;
return;
}
JSON::Object json = JSON::protobuf(healthCheck);
+ const string path = path::join(healthCheckDir, "mesos-health-check");
+
// Launch the subprocess using 'exec' style so that quotes can
// be properly handled.
vector<string> argv;
- string path = path::join(healthCheckDir, "mesos-health-check");
argv.push_back(path);
argv.push_back("--executor=" + stringify(self()));
argv.push_back("--health_check_json=" + stringify(json));
argv.push_back("--task_id=" + task.task_id().value());
- string cmd = strings::join(" ", argv);
+ const string cmd = strings::join(" ", argv);
+
cout << "Launching health check process: " << cmd << endl;
Try<Subprocess> healthProcess =