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:49 UTC

[5/9] mesos git commit: Propagated the container termination to the agent API.

Propagated the container termination to the agent API.

Updated the agent API so that we can propagate information
from the container termination up to the `WaitNestedContainer`
response. We now propagate resources all the way from the
container limitation to the `WaitNestedContainer` response so
that an executor can know specifically which resource limit
violation caused the container termination.

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


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

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

----------------------------------------------------------------------
 include/mesos/agent/agent.proto                 | 13 +++++++++++++
 include/mesos/slave/containerizer.proto         |  7 +++++++
 include/mesos/v1/agent/agent.proto              |  9 +++++++++
 src/slave/containerizer/mesos/containerizer.cpp |  5 +++++
 src/slave/http.cpp                              | 17 +++++++++++++++++
 5 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/98d96ca9/include/mesos/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/agent/agent.proto b/include/mesos/agent/agent.proto
index 527bcf2..4df3dce 100644
--- a/include/mesos/agent/agent.proto
+++ b/include/mesos/agent/agent.proto
@@ -338,6 +338,19 @@ message Response {
     // family of macros to extract whether the process exited cleanly and
     // what the exit code was.
     optional int32 exit_status = 1;
+
+    // The `state` and `reason` fields may be populated if the Mesos agent
+    // terminates the container. In the absence of any special knowledge,
+    // executors should propagate this information via the `status` field
+    // of an `Update` call for the corresponding TaskID.
+    optional TaskState state = 2;
+    optional TaskStatus.Reason reason = 3;
+
+    // This field will be populated if the task was terminated due to
+    // a resource limitation.
+    optional TaskResourceLimitation limitation = 4;
+
+    optional string message = 5;
   }
 
   optional Type type = 1;

http://git-wip-us.apache.org/repos/asf/mesos/blob/98d96ca9/include/mesos/slave/containerizer.proto
----------------------------------------------------------------------
diff --git a/include/mesos/slave/containerizer.proto b/include/mesos/slave/containerizer.proto
index 4375a38..689acfc 100644
--- a/include/mesos/slave/containerizer.proto
+++ b/include/mesos/slave/containerizer.proto
@@ -247,4 +247,11 @@ message ContainerTermination {
   optional TaskState state = 4;
   optional TaskStatus.Reason reason = 5;
   optional string message = 2;
+
+  // If the container was terminated due to a resource limitation,
+  // this is the resource that caused the termination.
+  //
+  // NOTE: 'Resources' is used here because the resource may span
+  // multiple roles (e.g. `"mem(*):1;mem(role):2"`).
+  repeated Resource limited_resources = 6;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/98d96ca9/include/mesos/v1/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/agent/agent.proto b/include/mesos/v1/agent/agent.proto
index be2a2f7..e99d23d 100644
--- a/include/mesos/v1/agent/agent.proto
+++ b/include/mesos/v1/agent/agent.proto
@@ -338,6 +338,15 @@ message Response {
     // family of macros to extract whether the process exited cleanly and
     // what the exit code was.
     optional int32 exit_status = 1;
+
+    optional TaskState state = 2;
+    optional TaskStatus.Reason reason = 3;
+
+    // This field will be populated if the task was terminated due to
+    // a resource limitation.
+    optional TaskResourceLimitation limitation = 4;
+
+    optional string message = 5;
   }
 
   optional Type type = 1;

http://git-wip-us.apache.org/repos/asf/mesos/blob/98d96ca9/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 23caba2..78fdd21 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -2685,6 +2685,11 @@ void MesosContainerizerProcess::limited(
     if (future->has_reason()) {
       termination->set_reason(future->reason());
     }
+
+    if (!future->resources().empty()) {
+        termination->mutable_limited_resources()->CopyFrom(
+            future->resources());
+    }
   } else {
     // TODO(idownes): A discarded future will not be an error when
     // isolators discard their promises after cleanup.

http://git-wip-us.apache.org/repos/asf/mesos/blob/98d96ca9/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index f4c3e6b..f2e06af 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -2512,6 +2512,23 @@ Future<Response> Http::waitNestedContainer(
             waitNestedContainer->set_exit_status(termination->status());
           }
 
+          if (termination->has_state()) {
+            waitNestedContainer->set_state(termination->state());
+          }
+
+          if (termination->has_reason()) {
+            waitNestedContainer->set_reason(termination->reason());
+          }
+
+          if (!termination->limited_resources().empty()) {
+            waitNestedContainer->mutable_limitation()->mutable_resources()
+              ->CopyFrom(termination->limited_resources());
+          }
+
+          if (termination->has_message()) {
+            waitNestedContainer->set_message(termination->message());
+          }
+
           return OK(serialize(acceptType, evolve(response)),
                     stringify(acceptType));
         });