You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/03/06 03:38:14 UTC

svn commit: r1453143 - /incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp

Author: vinodkone
Date: Wed Mar  6 02:38:13 2013
New Revision: 1453143

URL: http://svn.apache.org/r1453143
Log:
Added more user-friendly cgroups OOM messages.

From: Ben Mahler <be...@gmail.com>
Review: https://reviews.apache.org/r/9121

Modified:
    incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp

Modified: incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp?rev=1453143&r1=1453142&r2=1453143&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp Wed Mar  6 02:38:13 2013
@@ -33,6 +33,7 @@
 #include <process/defer.hpp>
 #include <process/dispatch.hpp>
 
+#include <stout/bytes.hpp>
 #include <stout/error.hpp>
 #include <stout/exit.hpp>
 #include <stout/foreach.hpp>
@@ -873,23 +874,38 @@ void CgroupsIsolationModule::oom(
   // Construct a "reason" string to describe why the isolation module
   // destroyed the executor's cgroup (in order to assist in debugging).
   ostringstream reason;
+  reason << "Memory limit exceeded: ";
 
   Try<string> read = cgroups::read(
       hierarchy, info->name(), "memory.limit_in_bytes");
   if (read.isSome()) {
-    reason << "MEMORY LIMIT: " << strings::trim(read.get()) << " bytes\n";
+    Try<uint64_t> bytes = numify<uint64_t>(strings::trim(read.get()));
+    if (bytes.isError()) {
+      LOG(ERROR)
+        << "Failed to numify 'memory.limit_in_bytes': " << bytes.error();
+      reason << "Requested: " << strings::trim(read.get()) << " bytes ";
+    } else {
+      reason << "Requested: " << Bytes(bytes.get()) << " ";
+    }
   }
 
   // Output 'memory.usage_in_bytes'.
   read = cgroups::read(hierarchy, info->name(), "memory.usage_in_bytes");
   if (read.isSome()) {
-    reason << "MEMORY USAGE: " << strings::trim(read.get()) << " bytes\n";
+    Try<uint64_t> bytes = numify<uint64_t>(strings::trim(read.get()));
+    if (bytes.isError()) {
+      LOG(ERROR)
+        << "Failed to numify 'memory.usage_in_bytes': " << bytes.error();
+      reason << "Used: " << strings::trim(read.get()) << " bytes\n";
+    } else {
+      reason << "Used: " << Bytes(bytes.get()) << "\n";
+    }
   }
 
   // Output 'memory.stat' of the cgroup to help with debugging.
   read = cgroups::read(hierarchy, info->name(), "memory.stat");
   if (read.isSome()) {
-    reason << "MEMORY STATISTICS: \n" << read.get() << "\n";
+    reason << "\nMEMORY STATISTICS: \n" << read.get() << "\n";
   }
 
   LOG(INFO) << strings::trim(reason.str()); // Trim the extra '\n' at the end.