You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2016/11/23 04:47:13 UTC

[4/6] mesos git commit: Improved Mesos containerizer invariant checking.

Improved Mesos containerizer invariant checking.

One of the reasons for MESOS-5763 is due to the lack invariant
checking. Mesos containerizer transitions the container state in
particular ways so when continuation chains could potentially be
interleaved with other actions we should verify the state transitions.

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


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

Branch: refs/heads/0.28.x
Commit: d7f8b8558974ee8739d460d53faf54a52832b754
Parents: 008e044
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Fri Jul 1 18:11:29 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Tue Nov 22 20:31:17 2016 -0800

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d7f8b855/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 59c2cd8..e902853 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -780,6 +780,8 @@ Future<bool> MesosContainerizerProcess::_launch(
     return Failure("Container is currently being destroyed");
   }
 
+  CHECK_EQ(containers_[containerId]->state, PROVISIONING);
+
   // We will provision the images specified in ContainerInfo::volumes
   // as well. We will mutate ContainerInfo::volumes to include the
   // paths to the provisioned root filesystems (by setting the
@@ -881,6 +883,8 @@ Future<list<Option<ContainerLaunchInfo>>> MesosContainerizerProcess::prepare(
     return Failure("Container is currently being destroyed");
   }
 
+  CHECK_EQ(containers_[containerId]->state, PROVISIONING);
+
   containers_[containerId]->state = PREPARING;
 
   // Construct ContainerConfig.
@@ -949,6 +953,8 @@ Future<Nothing> MesosContainerizerProcess::fetch(
     return Failure("Container is currently being destroyed");
   }
 
+  CHECK_EQ(containers_[containerId]->state, ISOLATING);
+
   containers_[containerId]->state = FETCHING;
 
   return fetcher->fetch(
@@ -981,6 +987,8 @@ Future<bool> MesosContainerizerProcess::__launch(
     return Failure("Container is currently being destroyed");
   }
 
+  CHECK_EQ(containers_[containerId]->state, PREPARING);
+
   // Prepare environment variables for the executor.
   map<string, string> environment = executorEnvironment(
       executorInfo,
@@ -1229,6 +1237,8 @@ Future<bool> MesosContainerizerProcess::isolate(
     return Failure("Container is currently being destroyed");
   }
 
+  CHECK_EQ(containers_[containerId]->state, PREPARING);
+
   containers_[containerId]->state = ISOLATING;
 
   // Set up callbacks for isolator limitations.
@@ -1266,6 +1276,8 @@ Future<bool> MesosContainerizerProcess::exec(
     return Failure("Container destroyed during launch");
   }
 
+  CHECK_EQ(containers_[containerId]->state, FETCHING);
+
   // Now that we've contained the child we can signal it to continue
   // by writing to the pipe.
   char dummy;
@@ -1547,6 +1559,8 @@ void MesosContainerizerProcess::destroy(
 void MesosContainerizerProcess::_destroy(
     const ContainerID& containerId)
 {
+  CHECK(containers_.contains(containerId));
+
   // Kill all processes then continue destruction.
   launcher->destroy(containerId)
     .onAny(defer(self(), &Self::__destroy, containerId, lambda::_1));
@@ -1595,6 +1609,8 @@ void MesosContainerizerProcess::___destroy(
     const Future<Option<int>>& status,
     const Option<string>& message)
 {
+  CHECK(containers_.contains(containerId));
+
   cleanupIsolators(containerId)
     .onAny(defer(self(),
                  &Self::____destroy,