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/03/22 00:57:41 UTC

mesos git commit: Cleaned up nested health checker launch code in command executor.

Repository: mesos
Updated Branches:
  refs/heads/master ed7037390 -> 30efac7ee


Cleaned up nested health checker launch code in command executor.

This trivial change adds logic to only invoke the health checker
if the task has an associated health check set. This also cleans
up nested \`if\` block making it more readable. This also cleans
up the logic to just return if the health check subprocess cannot
be created.

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


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

Branch: refs/heads/master
Commit: 30efac7eece04e22e9f381064666b927912684c0
Parents: ed70373
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Mon Mar 21 16:35:35 2016 -0700
Committer: Timothy Chen <tn...@apache.org>
Committed: Mon Mar 21 16:35:35 2016 -0700

----------------------------------------------------------------------
 src/launcher/executor.cpp | 71 ++++++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/30efac7e/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index 63eb8f1..2df62f0 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -442,7 +442,9 @@ public:
 
     cout << "Forked command at " << pid << endl;
 
-    launchHealthCheck(task);
+    if (task.has_health_check()) {
+      launchHealthCheck(task);
+    }
 
     // Monitor this process.
     process::reap(pid)
@@ -652,40 +654,41 @@ private:
 
   void launchHealthCheck(const TaskInfo& task)
   {
-    if (task.has_health_check()) {
-      JSON::Object json = JSON::protobuf(task.health_check());
-
-      // Launch the subprocess using 'exec' style so that quotes can
-      // be properly handled.
-      vector<string> argv(4);
-      argv[0] = "mesos-health-check";
-      argv[1] = "--executor=" + stringify(self());
-      argv[2] = "--health_check_json=" + stringify(json);
-      argv[3] = "--task_id=" + task.task_id().value();
-
-      cout << "Launching health check process: "
-           << path::join(healthCheckDir, "mesos-health-check")
-           << " " << argv[1] << " " << argv[2] << " " << argv[3] << endl;
-
-      Try<Subprocess> healthProcess =
-        process::subprocess(
-          path::join(healthCheckDir, "mesos-health-check"),
-          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));
-
-      if (healthProcess.isError()) {
-        cerr << "Unable to launch health process: " << healthProcess.error();
-      } else {
-        healthPid = healthProcess.get().pid();
-
-        cout << "Health check process launched at pid: "
-             << stringify(healthPid) << endl;
-      }
+    CHECK(task.has_health_check());
+
+    JSON::Object json = JSON::protobuf(task.health_check());
+
+    // Launch the subprocess using 'exec' style so that quotes can
+    // be properly handled.
+    vector<string> argv(4);
+    argv[0] = "mesos-health-check";
+    argv[1] = "--executor=" + stringify(self());
+    argv[2] = "--health_check_json=" + stringify(json);
+    argv[3] = "--task_id=" + task.task_id().value();
+
+    cout << "Launching health check process: "
+         << path::join(healthCheckDir, "mesos-health-check")
+         << " " << argv[1] << " " << argv[2] << " " << argv[3] << endl;
+
+    Try<Subprocess> healthProcess =
+      process::subprocess(
+        path::join(healthCheckDir, "mesos-health-check"),
+        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));
+
+    if (healthProcess.isError()) {
+      cerr << "Unable to launch health process: " << healthProcess.error();
+      return;
     }
+
+    healthPid = healthProcess.get().pid();
+
+    cout << "Health check process launched at pid: "
+         << stringify(healthPid) << endl;
   }
 
   enum State