You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jp...@apache.org on 2017/10/15 22:48:50 UTC

[6/9] mesos git commit: Added resources to the TaskStatus message.

Added resources to the TaskStatus message.

Added a TaskResourcesLimitation field to the `TaskStatus`
message to convey specific information about a resource
limit that has been violated by a container.

This field propagates the resources from the `ContainerLimitation`
message sent by isolators on the agent, and is populated for the
following reasons:

  * `REASON_CONTAINER_LIMITATION`
  * `REASON_CONTAINER_LIMITATION_DISK`
  * `REASON_CONTAINER_LIMITATION_MEMORY`

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


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

Branch: refs/heads/master
Commit: 4dd9ad6d5eb019e82d9cb00fe749ef7f8af65492
Parents: 98d96ca
Author: James Peach <jp...@apache.org>
Authored: Sun Oct 15 15:21:46 2017 -0700
Committer: James Peach <jp...@apache.org>
Committed: Sun Oct 15 15:21:46 2017 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto     |  4 ++++
 include/mesos/v1/mesos.proto  |  4 ++++
 src/common/protobuf_utils.cpp | 17 +++++++++++++++-
 src/common/protobuf_utils.hpp |  3 ++-
 src/slave/slave.cpp           | 41 +++++++++++++++++++++++++-------------
 5 files changed, 53 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4dd9ad6d/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 1d346d8..859fdff 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -2296,6 +2296,10 @@ message TaskStatus {
   // status updates for tasks running on agents that are unreachable
   // (e.g., partitioned away from the master).
   optional TimeInfo unreachable_time = 14;
+
+  // If the reason field indicates a container resource limitation,
+  // this field optionally contains additional information.
+  optional TaskResourceLimitation limitation = 16;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/4dd9ad6d/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 5049b8f..cfd4abd 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -2277,6 +2277,10 @@ message TaskStatus {
   // status updates for tasks running on agents that are unreachable
   // (e.g., partitioned away from the master).
   optional TimeInfo unreachable_time = 14;
+
+  // If the reason field indicates a container resource limitation,
+  // this field optionally contains additional information.
+  optional TaskResourceLimitation limitation = 16;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/4dd9ad6d/src/common/protobuf_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index 04f44f6..fd4858a 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -110,7 +110,8 @@ StatusUpdate createStatusUpdate(
     const Option<CheckStatusInfo>& checkStatus,
     const Option<Labels>& labels,
     const Option<ContainerStatus>& containerStatus,
-    const Option<TimeInfo>& unreachableTime)
+    const Option<TimeInfo>& unreachableTime,
+    const Option<Resources>& limitedResources)
 {
   StatusUpdate update;
 
@@ -168,6 +169,20 @@ StatusUpdate createStatusUpdate(
     status->mutable_unreachable_time()->CopyFrom(unreachableTime.get());
   }
 
+  if (limitedResources.isSome()) {
+    // Check that we are only sending the `Limitation` field when the
+    // reason is a container limitation.
+    CHECK_SOME(reason);
+    CHECK(
+        reason.get() == TaskStatus::REASON_CONTAINER_LIMITATION ||
+        reason.get() == TaskStatus::REASON_CONTAINER_LIMITATION_DISK ||
+        reason.get() == TaskStatus::REASON_CONTAINER_LIMITATION_MEMORY)
+      << reason.get();
+
+    status->mutable_limitation()->mutable_resources()->CopyFrom(
+        limitedResources.get());
+  }
+
   return update;
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/4dd9ad6d/src/common/protobuf_utils.hpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.hpp b/src/common/protobuf_utils.hpp
index ff0fd01..c43ab75 100644
--- a/src/common/protobuf_utils.hpp
+++ b/src/common/protobuf_utils.hpp
@@ -88,7 +88,8 @@ StatusUpdate createStatusUpdate(
     const Option<CheckStatusInfo>& checkStatus = None(),
     const Option<Labels>& labels = None(),
     const Option<ContainerStatus>& containerStatus = None(),
-    const Option<TimeInfo>& unreachableTime = None());
+    const Option<TimeInfo>& unreachableTime = None(),
+    const Option<Resources>& limitedResources = None());
 
 
 StatusUpdate createStatusUpdate(

http://git-wip-us.apache.org/repos/asf/mesos/blob/4dd9ad6d/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index df0e894..4d7dc8e 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -6890,9 +6890,10 @@ void Slave::sendExecutorTerminatedStatusUpdate(
   TaskStatus::Reason reason;
   string message;
 
+  const bool haveTermination = termination.isReady() && termination->isSome();
+
   // Determine the task state for the status update.
-  if (termination.isReady() &&
-      termination->isSome() && termination->get().has_state()) {
+  if (haveTermination && termination->get().has_state()) {
     state = termination->get().state();
   } else if (executor->pendingTermination.isSome() &&
              executor->pendingTermination->has_state()) {
@@ -6902,8 +6903,7 @@ void Slave::sendExecutorTerminatedStatusUpdate(
   }
 
   // Determine the task reason for the status update.
-  if (termination.isReady() &&
-      termination->isSome() && termination->get().has_reason()) {
+  if (haveTermination && termination->get().has_reason()) {
     reason = termination->get().reason();
   } else if (executor->pendingTermination.isSome() &&
              executor->pendingTermination->has_reason()) {
@@ -6936,16 +6936,29 @@ void Slave::sendExecutorTerminatedStatusUpdate(
     message = strings::join("; ", messages);
   }
 
-  statusUpdate(protobuf::createStatusUpdate(
-      frameworkId,
-      info.id(),
-      taskId,
-      state,
-      TaskStatus::SOURCE_SLAVE,
-      UUID::random(),
-      message,
-      reason,
-      executor->id),
+  Option<Resources> limitedResources;
+
+  if (haveTermination && !termination->get().limited_resources().empty()) {
+    limitedResources = termination->get().limited_resources();
+  }
+
+  statusUpdate(
+      protobuf::createStatusUpdate(
+          frameworkId,
+          info.id(),
+          taskId,
+          state,
+          TaskStatus::SOURCE_SLAVE,
+          UUID::random(),
+          message,
+          reason,
+          executor->id,
+          None(),
+          None(),
+          None(),
+          None(),
+          None(),
+          limitedResources),
       UPID());
 }