You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/12/19 18:42:35 UTC

[2/2] mesos git commit: Added logging based on container class.

Added logging based on container class.

This change adjusts log level based on the container class.
If the class is `DEBUG` we print the log entry at a verbose
level 1, otherwise we print it at the `INFO` level.

We use the added macro in mesos containerizer so that COMMAND
checks cause less INFO logs (15 lines instead of 26 before).

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


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

Branch: refs/heads/master
Commit: 82979512bbdabb53318bcfef37729355917fb46c
Parents: e809c3e
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Tue Dec 19 19:41:10 2017 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Tue Dec 19 19:42:01 2017 +0100

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 37 ++++++++++++--------
 src/slave/containerizer/mesos/containerizer.hpp |  7 ++++
 2 files changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/82979512/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 0504cf9..cddc617 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1169,8 +1169,9 @@ Future<Containerizer::LaunchResult> MesosContainerizerProcess::launch(
 
 #ifndef __WINDOWS__
     if (containerConfig.has_user()) {
-      LOG(INFO) << "Trying to chown '" << directory << "' to user '"
-                << containerConfig.user() << "'";
+      LOG_BASED_ON_CLASS(containerConfig.container_class())
+        << "Trying to chown '" << directory << "' to user '"
+        << containerConfig.user() << "'";
 
       Try<Nothing> chown = os::chown(containerConfig.user(), directory);
       if (chown.isError()) {
@@ -1203,7 +1204,8 @@ Future<Containerizer::LaunchResult> MesosContainerizerProcess::launch(
     }
   }
 
-  LOG(INFO) << "Starting container " << containerId;
+  LOG_BASED_ON_CLASS(containerConfig.container_class())
+    << "Starting container " << containerId;
 
   // Before we launch the container, we first create the container
   // runtime directory to hold internal checkpoint information about
@@ -1943,8 +1945,9 @@ Future<Containerizer::LaunchResult> MesosContainerizerProcess::_launch(
 
   // Checkpoint the forked pid if requested by the agent.
   if (pidCheckpointPath.isSome()) {
-    LOG(INFO) << "Checkpointing container's forked pid " << pid
-              << " to '" << pidCheckpointPath.get() << "'";
+    LOG_BASED_ON_CLASS(container->containerClass())
+      << "Checkpointing container's forked pid " << pid
+      << " to '" << pidCheckpointPath.get() << "'";
 
     Try<Nothing> checkpointed =
       slave::state::checkpoint(pidCheckpointPath.get(), stringify(pid));
@@ -2346,8 +2349,9 @@ Future<bool> MesosContainerizerProcess::destroy(
       .then([]() { return true; });
   }
 
-  LOG(INFO) << "Destroying container " << containerId << " in "
-            << container->state << " state";
+  LOG_BASED_ON_CLASS(container->containerClass())
+    << "Destroying container " << containerId << " in "
+    << container->state << " state";
 
   // NOTE: We save the previous state so that '_destroy' can properly
   // cleanup based on the previous state of the container.
@@ -2635,8 +2639,9 @@ void MesosContainerizerProcess::______destroy(
     const string terminationPath =
       path::join(runtimePath, containerizer::paths::TERMINATION_FILE);
 
-    LOG(INFO) << "Checkpointing termination state to nested container's"
-              << " runtime directory '" << terminationPath << "'";
+    LOG_BASED_ON_CLASS(container->containerClass())
+      << "Checkpointing termination state to nested container's runtime"
+      << " directory '" << terminationPath << "'";
 
     Try<Nothing> checkpointed =
       slave::state::checkpoint(terminationPath, termination);
@@ -2797,7 +2802,8 @@ void MesosContainerizerProcess::reaped(const ContainerID& containerId)
     return;
   }
 
-  LOG(INFO) << "Container " << containerId << " has exited";
+  LOG_BASED_ON_CLASS(containers_.at(containerId)->containerClass())
+    << "Container " << containerId << " has exited";
 
   // The executor has exited so destroy the container.
   destroy(containerId, None());
@@ -2816,9 +2822,9 @@ void MesosContainerizerProcess::limited(
   Option<ContainerTermination> termination = None();
 
   if (future.isReady()) {
-    LOG(INFO) << "Container " << containerId << " has reached its limit for"
-              << " resource " << future.get().resources()
-              << " and will be terminated";
+    LOG_BASED_ON_CLASS(containers_.at(containerId)->containerClass())
+      << "Container " << containerId << " has reached its limit for resource "
+      << future.get().resources() << " and will be terminated";
 
     termination = ContainerTermination();
     termination->set_state(TaskState::TASK_FAILED);
@@ -2957,8 +2963,9 @@ void MesosContainerizerProcess::transition(
 
   const Owned<Container>& container = containers_.at(containerId);
 
-  LOG(INFO) << "Transitioning the state of container " << containerId
-            << " from " << container->state << " to " << state;
+  LOG_BASED_ON_CLASS(container->containerClass())
+    << "Transitioning the state of container " << containerId << " from "
+    << container->state << " to " << state;
 
   container->state = state;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/82979512/src/slave/containerizer/mesos/containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.hpp b/src/slave/containerizer/mesos/containerizer.hpp
index 6a141eb..cba4ed2 100644
--- a/src/slave/containerizer/mesos/containerizer.hpp
+++ b/src/slave/containerizer/mesos/containerizer.hpp
@@ -51,6 +51,13 @@ namespace mesos {
 namespace internal {
 namespace slave {
 
+// If the container class is not of type `DEBUG` (i.e., it is not set or
+// `DEFAULT`), we log the line at the INFO level. Otherwise, we use VLOG(1).
+// The purpose of this macro is to avoid polluting agent logs with information
+// related to `DEBUG` containers as this type of container can run periodically.
+#define LOG_BASED_ON_CLASS(containerClass) \
+  LOG_IF(INFO, (containerClass != ContainerClass::DEBUG) || VLOG_IS_ON(1))
+
 // Forward declaration.
 class MesosContainerizerProcess;