Repository: mesos
Updated Branches:
  refs/heads/master 63004cc49 -> a4fd86bce


Made the 'disk/du' isolator nesting aware.

The disk space check will be done at the top container level. All
nested container will not have separate disk space check for now.

In theory, this change is not necessary for now as we can simply mark
the isolator as nesting unaware. However, in the future, we might want
to do separate disk check for each nested container and report
limitations for them. Therefore, we include this patch as a starting
point.

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


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

Branch: refs/heads/master
Commit: a4fd86bce2d2b6b53bce2ea95e3b69c5ab011ff8
Parents: 8221021
Author: Jie Yu <yujie....@gmail.com>
Authored: Sat Sep 17 12:26:52 2016 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Sat Sep 17 13:02:37 2016 -0700

----------------------------------------------------------------------
 .../mesos/isolators/posix/disk.cpp              | 45 ++++++++++++++++++++
 .../mesos/isolators/posix/disk.hpp              |  2 +
 2 files changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a4fd86bc/src/slave/containerizer/mesos/isolators/posix/disk.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/posix/disk.cpp 
b/src/slave/containerizer/mesos/isolators/posix/disk.cpp
index 5b9d5aa..3f49b9f 100644
--- a/src/slave/containerizer/mesos/isolators/posix/disk.cpp
+++ b/src/slave/containerizer/mesos/isolators/posix/disk.cpp
@@ -108,11 +108,24 @@ PosixDiskIsolatorProcess::PosixDiskIsolatorProcess(const 
Flags& _flags)
 PosixDiskIsolatorProcess::~PosixDiskIsolatorProcess() {}
 
 
+bool PosixDiskIsolatorProcess::supportsNesting()
+{
+  return true;
+}
+
+
 Future<Nothing> PosixDiskIsolatorProcess::recover(
     const list<ContainerState>& states,
     const hashset<ContainerID>& orphans)
 {
   foreach (const ContainerState& state, states) {
+    // If this is a nested container, we do not need to create an Info
+    // struct for it because we only perform disk space check for the
+    // top level container.
+    if (state.container_id().has_parent()) {
+      continue;
+    }
+
     // Since we checkpoint the executor after we create its working
     // directory, the working directory should definitely exist.
     CHECK(os::exists(state.directory()))
@@ -129,6 +142,13 @@ Future<Option<ContainerLaunchInfo>> 
PosixDiskIsolatorProcess::prepare(
     const ContainerID& containerId,
     const ContainerConfig& containerConfig)
 {
+  // If this is a nested container, we do not need to create an Info
+  // struct for it because we only perform disk space check for the
+  // top level container.
+  if (containerId.has_parent()) {
+    return None();
+  }
+
   if (infos.contains(containerId)) {
     return Failure("Container has already been prepared");
   }
@@ -143,6 +163,10 @@ Future<Nothing> PosixDiskIsolatorProcess::isolate(
     const ContainerID& containerId,
     pid_t pid)
 {
+  if (containerId.has_parent()) {
+    return Nothing();
+  }
+
   if (!infos.contains(containerId)) {
     return Failure("Unknown container");
   }
@@ -154,6 +178,13 @@ Future<Nothing> PosixDiskIsolatorProcess::isolate(
 Future<ContainerLimitation> PosixDiskIsolatorProcess::watch(
     const ContainerID& containerId)
 {
+  // Since we are not doing disk space check for nested containers
+  // currently, we simply return a pending future here, indicating
+  // that the limit for the nested container will not be reached.
+  if (containerId.has_parent()) {
+    return Future<ContainerLimitation>();
+  }
+
   if (!infos.contains(containerId)) {
     return Failure("Unknown container");
   }
@@ -166,6 +197,10 @@ Future<Nothing> PosixDiskIsolatorProcess::update(
     const ContainerID& containerId,
     const Resources& resources)
 {
+  if (containerId.has_parent()) {
+    return Failure("Not supported for nested containers");
+  }
+
   if (!infos.contains(containerId)) {
     LOG(WARNING) << "Ignoring update for unknown container " << containerId;
     return Nothing();
@@ -339,6 +374,10 @@ void PosixDiskIsolatorProcess::_collect(
 Future<ResourceStatistics> PosixDiskIsolatorProcess::usage(
     const ContainerID& containerId)
 {
+  if (containerId.has_parent()) {
+    return Failure("Not supported for nested containers");
+  }
+
   if (!infos.contains(containerId)) {
     return Failure("Unknown container");
   }
@@ -369,6 +408,12 @@ Future<ResourceStatistics> PosixDiskIsolatorProcess::usage(
 Future<Nothing> PosixDiskIsolatorProcess::cleanup(
     const ContainerID& containerId)
 {
+  // No need to cleanup anything because we don't create Info struct
+  // for nested containers.
+  if (containerId.has_parent()) {
+    return Nothing();
+  }
+
   if (!infos.contains(containerId)) {
     LOG(WARNING) << "Ignoring cleanup for unknown container " << containerId;
     return Nothing();

http://git-wip-us.apache.org/repos/asf/mesos/blob/a4fd86bc/src/slave/containerizer/mesos/isolators/posix/disk.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/posix/disk.hpp 
b/src/slave/containerizer/mesos/isolators/posix/disk.hpp
index 3998251..6368429 100644
--- a/src/slave/containerizer/mesos/isolators/posix/disk.hpp
+++ b/src/slave/containerizer/mesos/isolators/posix/disk.hpp
@@ -78,6 +78,8 @@ public:
 
   virtual ~PosixDiskIsolatorProcess();
 
+  virtual bool supportsNesting();
+
   virtual process::Future<Nothing> recover(
       const std::list<mesos::slave::ContainerState>& states,
       const hashset<ContainerID>& orphans);

Reply via email to