Used 'undiscardable' to protect a future in MesosContainerizer.

This patch addressed MESOS-7926 by protecting 'termination.future()'
with 'undiscardable'. This prevented the upstream discard event from
being propagated into 'termination.future()' which gets reused for
other calls.

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


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

Branch: refs/heads/1.3.x
Commit: 6c09aa2cc2744f244196336954892e8287b1bc17
Parents: 4846a5b
Author: Jie Yu <yujie....@gmail.com>
Authored: Wed Aug 30 17:28:05 2017 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Thu Aug 31 19:55:02 2017 -0700

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6c09aa2c/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp 
b/src/slave/containerizer/mesos/containerizer.cpp
index 6d0e269..ffb6c79 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1929,7 +1929,12 @@ Future<Option<ContainerTermination>> 
MesosContainerizerProcess::wait(
     return None();
   }
 
-  return containers_.at(containerId)->termination.future()
+  // NOTE: Use 'undiscardable' here to make sure discard from the
+  // caller does not propagate into 'termination.future()' which will
+  // be used in 'destroy()'. We don't want a discard on 'wait()' call
+  // to affect future calls to 'destroy()'. See more details in
+  // MESOS-7926.
+  return undiscardable(containers_.at(containerId)->termination.future())
     .then(Option<ContainerTermination>::some);
 }
 
@@ -2126,7 +2131,12 @@ Future<bool> MesosContainerizerProcess::destroy(
   const Owned<Container>& container = containers_.at(containerId);
 
   if (container->state == DESTROYING) {
-    return container->termination.future()
+    // NOTE: Use 'undiscardable' here to make sure discard from the
+    // caller does not propagate into 'termination.future()' which
+    // will be used in 'wait()'. We don't want a discard on
+    // 'destroy()' call to affect future calls to 'wait()'. See more
+    // details in MESOS-7926.
+    return undiscardable(container->termination.future())
       .then([]() { return true; });
   }
 
@@ -2150,7 +2160,12 @@ Future<bool> MesosContainerizerProcess::destroy(
       return Nothing();
     }));
 
-  return container->termination.future()
+  // NOTE: Use 'undiscardable' here to make sure discard from the
+  // caller does not propagate into 'termination.future()' which will
+  // be used in 'wait()'. We don't want a discard on 'destroy()' call
+  // to affect future calls to 'wait()'. See more details in
+  // MESOS-7926.
+  return undiscardable(container->termination.future())
     .then([]() { return true; });
 }
 

Reply via email to