You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2016/07/06 21:54:09 UTC

[4/5] 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/8907b5d5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8907b5d5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8907b5d5

Branch: refs/heads/master
Commit: 8907b5d5e1f007c4592a0417a4d9f20d7e1f8efd
Parents: 48b1bfa
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Fri Jul 1 18:11:29 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Wed Jul 6 14:53:46 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/8907b5d5/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 0b2abba..fe6ddc8 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -895,6 +895,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
@@ -996,6 +998,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.
@@ -1056,6 +1060,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(
@@ -1094,6 +1100,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,
@@ -1355,6 +1363,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.
@@ -1392,6 +1402,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;
@@ -1674,6 +1686,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));
@@ -1722,6 +1736,8 @@ void MesosContainerizerProcess::___destroy(
     const Future<Option<int>>& status,
     const Option<string>& message)
 {
+  CHECK(containers_.contains(containerId));
+
   cleanupIsolators(containerId)
     .onAny(defer(self(),
                  &Self::____destroy,