Ensured that Docker containerizer returns a failed Future in one case.

Because the Docker library did not immediately transition the
Future returned by `inspect()` to DISCARDED, it was safe for the
Docker containerizer to discard this Future before failing the
Promise associated with the Future returned by `launch()`.

However, the introduction of an `onDiscard` callback in
`Docker::inspect()` makes this assumption invalid. This patch
addresses this by failing the Promise before discarding the
Future.

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


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

Branch: refs/heads/1.3.x
Commit: 94496104a1e29aef262b2a9817e1c0f96290c874
Parents: 6d8b9b7
Author: Greg Mann <g...@mesosphere.io>
Authored: Tue Feb 27 16:42:10 2018 -0800
Committer: Gilbert Song <songzihao1...@gmail.com>
Committed: Mon Mar 5 18:14:59 2018 -0800

----------------------------------------------------------------------
 src/slave/containerizer/docker.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/94496104/src/slave/containerizer/docker.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/docker.cpp 
b/src/slave/containerizer/docker.cpp
index fb3d0ea..02cd36a 100644
--- a/src/slave/containerizer/docker.cpp
+++ b/src/slave/containerizer/docker.cpp
@@ -1454,15 +1454,15 @@ Future<Docker::Container> 
DockerContainerizerProcess::launchExecutorContainer(
 
     run.onAny([=]() mutable {
       if (!run.isReady()) {
-        inspect.discard();
         promise->fail(run.isFailed() ? run.failure() : "discarded");
-      } else if (run->isNone()) {
         inspect.discard();
+      } else if (run->isNone()) {
         promise->fail("Failed to obtain exit status of container");
+        inspect.discard();
       } else {
         if (!WSUCCEEDED(run->get())) {
-          inspect.discard();
           promise->fail("Container " + WSTRINGIFY(run->get()));
+          inspect.discard();
         }
 
         // TODO(bmahler): Handle the case where the 'run' exits

Reply via email to