Resumed the clock if necessary when destroying test agent.

Because the `cgroups::destroy()` code path makes use of `delay()`,
the clock must not be paused in order for the destructor of the
test `Slave` to reliably destroy all remaining containers.

This patch updates the destructor to check if the clock is paused
and, if so, resume it before destroying containers.

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


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

Branch: refs/heads/master
Commit: 434ef5f431d62113d649e7a7c946c55d43a8034a
Parents: 69e5e28
Author: Greg Mann <g...@mesosphere.io>
Authored: Fri Jan 19 15:36:29 2018 -0800
Committer: Greg Mann <gregorywm...@gmail.com>
Committed: Fri Jan 19 15:50:32 2018 -0800

----------------------------------------------------------------------
 src/tests/cluster.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/434ef5f4/src/tests/cluster.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cluster.cpp b/src/tests/cluster.cpp
index 568c9c7..19a41c7 100644
--- a/src/tests/cluster.cpp
+++ b/src/tests/cluster.cpp
@@ -641,6 +641,16 @@ Slave::~Slave()
 
     AWAIT_READY(containers);
 
+    // Because the `cgroups::destroy()` code path makes use of `delay()`, the
+    // clock must not be paused in order to reliably destroy all remaining
+    // containers. If necessary, we resume the clock here and then pause it
+    // again when we're done destroying containers.
+    bool paused = process::Clock::paused();
+
+    if (paused) {
+      process::Clock::resume();
+    }
+
     foreach (const ContainerID& containerId, containers.get()) {
       process::Future<Option<ContainerTermination>> wait =
         containerizer->wait(containerId);
@@ -656,6 +666,10 @@ Slave::~Slave()
       }
     }
 
+    if (paused) {
+      process::Clock::pause();
+    }
+
     containers = containerizer->containers();
     AWAIT_READY(containers);
 

Reply via email to