Repository: mesos
Updated Branches:
  refs/heads/master bc6b61bca -> 7af86dd15


Destroyed nested container on `attachContainerOutput` failure.

After launching a container, the `LAUNCH_NESTED_CONTAINER_SESSION`
handler calls into `attachContainerOutput()`. Previously, if
`attachContainerOutput()` returned an HTTP response code other than
200, we didn't destroy the nested container. From the point of view of
API users, if `LAUNCH_NESTED_CONTAINER_SESSION` returns an error, then
no nested container should be left in the `RUNNING` state. This patch
fixes this issue by destroying the nested container when HTTP errors
are returned by this call to `attachContainerOutput()`.

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


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

Branch: refs/heads/master
Commit: 7af86dd1569d0ea3fe75f92bcc9b826a46c5968d
Parents: bc6b61b
Author: Andrei Budnik <abud...@mesosphere.com>
Authored: Tue Feb 13 10:53:30 2018 -0800
Committer: Greg Mann <gregorywm...@gmail.com>
Committed: Tue Feb 13 11:57:15 2018 -0800

----------------------------------------------------------------------
 src/slave/http.cpp | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7af86dd1/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 77e711c..59eef7a 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -3548,6 +3548,11 @@ Future<Response> Http::launchNestedContainerSession(
         .then(defer(slave->self(),
                     [=](const Response& response) -> Future<Response> {
           if (response.status != OK().status) {
+            LOG(WARNING) << "Failed to attach to nested container "
+                         << containerId << ": '" << response.status << "' ("
+                         << response.body << ")";
+
+            destroy(containerId);
             return response;
           }
 

Reply via email to