You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2017/08/21 22:46:37 UTC

[1/3] mesos git commit: Included nested command check output in the executor logs.

Repository: mesos
Updated Branches:
  refs/heads/master a702e1a79 -> 8347ec09f


Included nested command check output in the executor logs.

This patch updates the checker and health checker to include the output
of COMMAND checks and health checks in its logs by default. This has
the effect of including these logs in the executor output for easier
debugging.

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


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

Branch: refs/heads/master
Commit: 0a01bc38eba08da8ef8b4ae152c95a57c39d73f3
Parents: a702e1a
Author: Gastón Kleiman <ga...@mesosphere.io>
Authored: Mon Aug 21 15:28:36 2017 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Mon Aug 21 15:37:55 2017 -0700

----------------------------------------------------------------------
 src/checks/checker_process.cpp | 70 +++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0a01bc38/src/checks/checker_process.cpp
----------------------------------------------------------------------
diff --git a/src/checks/checker_process.cpp b/src/checks/checker_process.cpp
index 30dda0e..f4b7330 100644
--- a/src/checks/checker_process.cpp
+++ b/src/checks/checker_process.cpp
@@ -41,11 +41,13 @@
 
 #include <stout/check.hpp>
 #include <stout/duration.hpp>
+#include <stout/error.hpp>
 #include <stout/foreach.hpp>
 #include <stout/jsonify.hpp>
 #include <stout/nothing.hpp>
 #include <stout/option.hpp>
 #include <stout/protobuf.hpp>
+#include <stout/recordio.hpp>
 #include <stout/stopwatch.hpp>
 #include <stout/strings.hpp>
 #include <stout/try.hpp>
@@ -138,6 +140,49 @@ static pid_t cloneWithSetns(
 #endif
 
 
+// Reads `ProcessIO::Data` records from a string containing "Record-IO"
+// data encoded in protobuf messages, and returns the stdout and stderr.
+//
+// NOTE: This function ignores any `ProcessIO::Control` records.
+//
+// TODO(gkleiman): This function is very similar to one in `api_tests.cpp`, we
+// should refactor them into a common helper when fixing MESOS-7903.
+static Try<tuple<string, string>> decodeProcessIOData(const string& data)
+{
+  string stdoutReceived;
+  string stderrReceived;
+
+  recordio::Decoder<v1::agent::ProcessIO> decoder(
+      lambda::bind(
+          deserialize<v1::agent::ProcessIO>,
+          ContentType::PROTOBUF,
+          lambda::_1));
+
+  Try<std::deque<Try<v1::agent::ProcessIO>>> records = decoder.decode(data);
+
+  if (records.isError()) {
+    return Error(records.error());
+  }
+
+  while (!records->empty()) {
+    Try<v1::agent::ProcessIO> record = records->front();
+    records->pop_front();
+
+    if (record.isError()) {
+      return Error(record.error());
+    }
+
+    if (record->data().type() == v1::agent::ProcessIO::Data::STDOUT) {
+      stdoutReceived += record->data().data();
+    } else if (record->data().type() == v1::agent::ProcessIO::Data::STDERR) {
+      stderrReceived += record->data().data();
+    }
+  }
+
+  return std::make_tuple(stdoutReceived, stderrReceived);
+}
+
+
 CheckerProcess::CheckerProcess(
     const CheckInfo& _check,
     const string& _launcherDir,
@@ -542,6 +587,10 @@ void CheckerProcess::__nestedCommandCheck(
   //
   // This means that this future will not be completed until after the
   // check command has finished or the connection has been closed.
+  //
+  // TODO(gkleiman): The output of timed-out checks is lost, we'll
+  // probably have to call `Connection::send` with `streamed = true`
+  // to be able to log it. See MESOS-7903.
   connection.send(request, false)
     .after(checkTimeout,
            defer(self(),
@@ -583,6 +632,27 @@ void CheckerProcess::___nestedCommandCheck(
     return;
   }
 
+  Try<tuple<string, string>> checkOutput =
+    decodeProcessIOData(launchResponse.body);
+
+  if (checkOutput.isError()) {
+    LOG(WARNING) << "Failed to decode the output of the " << name
+                 << " for task '" << taskId << "': " << checkOutput.error();
+  } else {
+    string stdoutReceived;
+    string stderrReceived;
+
+    tie(stdoutReceived, stderrReceived) = checkOutput.get();
+
+    LOG(INFO) << "Output of the " << name << " for task '" << taskId
+              << "' (stdout):" << std::endl
+              << stdoutReceived;
+
+    LOG(INFO) << "Output of the " << name << " for task '" << taskId
+              << "' (stderr):" << std::endl
+              << stderrReceived;
+  }
+
   waitNestedContainer(checkContainerId)
     .onFailed([promise](const string& failure) {
       promise->fail(


[2/3] mesos git commit: Made the log output handling of TCP and HTTP checks consistent.

Posted by gr...@apache.org.
Made the log output handling of TCP and HTTP checks consistent.

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


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

Branch: refs/heads/master
Commit: 6d778fa45a73723b857db9b2ce92c3d15fb3373f
Parents: 0a01bc3
Author: Gastón Kleiman <ga...@mesosphere.io>
Authored: Mon Aug 21 15:28:37 2017 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Mon Aug 21 15:43:11 2017 -0700

----------------------------------------------------------------------
 src/checks/checker_process.cpp | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6d778fa4/src/checks/checker_process.cpp
----------------------------------------------------------------------
diff --git a/src/checks/checker_process.cpp b/src/checks/checker_process.cpp
index f4b7330..657e6c0 100644
--- a/src/checks/checker_process.cpp
+++ b/src/checks/checker_process.cpp
@@ -914,32 +914,35 @@ Future<int> CheckerProcess::_httpCheck(
 
   int exitCode = status->get();
   if (exitCode != 0) {
-    const Future<string>& error = std::get<2>(t);
-    if (!error.isReady()) {
+    const Future<string>& commandError = std::get<2>(t);
+    if (!commandError.isReady()) {
       return Failure(
           string(HTTP_CHECK_COMMAND) + " " + WSTRINGIFY(exitCode) +
           "; reading stderr failed: " +
-          (error.isFailed() ? error.failure() : "discarded"));
+          (commandError.isFailed() ? commandError.failure() : "discarded"));
     }
 
     return Failure(
         string(HTTP_CHECK_COMMAND) + " " + WSTRINGIFY(exitCode) + ": " +
-        error.get());
+        commandError.get());
   }
 
-  const Future<string>& output = std::get<1>(t);
-  if (!output.isReady()) {
+  const Future<string>& commandOutput = std::get<1>(t);
+  if (!commandOutput.isReady()) {
     return Failure(
         "Failed to read stdout from " + string(HTTP_CHECK_COMMAND) + ": " +
-        (output.isFailed() ? output.failure() : "discarded"));
+        (commandOutput.isFailed() ? commandOutput.failure() : "discarded"));
   }
 
+  VLOG(1) << "Output of the " << name << " for task '" << taskId
+          << "': " << commandOutput.get();
+
   // Parse the output and get the HTTP status code.
-  Try<int> statusCode = numify<int>(output.get());
+  Try<int> statusCode = numify<int>(commandOutput.get());
   if (statusCode.isError()) {
     return Failure(
         "Unexpected output from " + string(HTTP_CHECK_COMMAND) + ": " +
-        output.get());
+        commandOutput.get());
   }
 
   return statusCode.get();
@@ -1068,7 +1071,8 @@ Future<bool> CheckerProcess::_tcpCheck(
 
   const Future<string>& commandOutput = std::get<1>(t);
   if (commandOutput.isReady()) {
-    VLOG(1) << string(TCP_CHECK_COMMAND) << ": " << commandOutput.get();
+    VLOG(1) << "Output of the " << name << " for task '" << taskId
+            << "': " << commandOutput.get();
   }
 
   if (exitCode != 0) {


[3/3] mesos git commit: Raised the logging level of some check and health check messages.

Posted by gr...@apache.org.
Raised the logging level of some check and health check messages.

Some users pointed out that always logging the result of checks and
health checks makes it easier to debug problems.

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


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

Branch: refs/heads/master
Commit: 8347ec09f15989b822f48c000043c6547c25b5f4
Parents: 6d778fa
Author: Gastón Kleiman <ga...@mesosphere.io>
Authored: Mon Aug 21 15:28:39 2017 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Mon Aug 21 15:43:29 2017 -0700

----------------------------------------------------------------------
 src/checks/checker_process.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8347ec09/src/checks/checker_process.cpp
----------------------------------------------------------------------
diff --git a/src/checks/checker_process.cpp b/src/checks/checker_process.cpp
index 657e6c0..4aa5b2d 100644
--- a/src/checks/checker_process.cpp
+++ b/src/checks/checker_process.cpp
@@ -797,7 +797,7 @@ void CheckerProcess::processCommandCheckResult(
   // see MESOS-7242.
   if (future.isReady() && WIFEXITED(future.get())) {
     const int exitCode = WEXITSTATUS(future.get());
-    VLOG(1) << name << " for task '" << taskId << "' returned: " << exitCode;
+    LOG(INFO) << name << " for task '" << taskId << "' returned: " << exitCode;
 
     CheckStatusInfo checkStatusInfo;
     checkStatusInfo.set_type(check.type());
@@ -958,8 +958,8 @@ void CheckerProcess::processHttpCheckResult(
   Result<CheckStatusInfo> result = None();
 
   if (future.isReady()) {
-    VLOG(1) << name << " for task '" << taskId << "'"
-            << " returned: " << future.get();
+    LOG(INFO) << name << " for task '" << taskId << "'"
+              << " returned: " << future.get();
 
     CheckStatusInfo checkStatusInfo;
     checkStatusInfo.set_type(check.type());
@@ -1099,8 +1099,8 @@ void CheckerProcess::processTcpCheckResult(
   Result<CheckStatusInfo> result = None();
 
   if (future.isReady()) {
-    VLOG(1) << name << " for task '" << taskId << "'"
-            << " returned: " << future.get();
+    LOG(INFO) << name << " for task '" << taskId << "'"
+              << " returned: " << future.get();
 
     CheckStatusInfo checkStatusInfo;
     checkStatusInfo.set_type(check.type());