You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/07/27 22:37:07 UTC

mesos git commit: Implemented `CgroupsIsolatorProcess::isolate`.

Repository: mesos
Updated Branches:
  refs/heads/master 9fb0b2a30 -> 10f029bfd


Implemented `CgroupsIsolatorProcess::isolate`.

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


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

Branch: refs/heads/master
Commit: 10f029bfd839c47f62b72c81146cc481ab83216c
Parents: 9fb0b2a
Author: haosdent huang <ha...@gmail.com>
Authored: Wed Jul 27 15:08:02 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jul 27 15:36:29 2016 -0700

----------------------------------------------------------------------
 .../mesos/isolators/cgroups/cgroups.cpp         | 30 +++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/10f029bf/src/slave/containerizer/mesos/isolators/cgroups/cgroups.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/cgroups/cgroups.cpp b/src/slave/containerizer/mesos/isolators/cgroups/cgroups.cpp
index 381250b..364bc77 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups/cgroups.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups/cgroups.cpp
@@ -220,7 +220,35 @@ Future<Nothing> CgroupsIsolatorProcess::isolate(
     const ContainerID& containerId,
     pid_t pid)
 {
-  return Failure("Not implemented.");
+  if (!infos.contains(containerId)) {
+    return Failure("Failed to isolate the container: Unknown container");
+  }
+
+  // TODO(haosdent): Use foreachkey once MESOS-5037 is resolved.
+  foreach (const string& hierarchy, subsystems.keys()) {
+    Try<Nothing> assign = cgroups::assign(
+        hierarchy,
+        infos[containerId]->cgroup,
+        pid);
+
+    if (assign.isError()) {
+      string message =
+        "Failed to assign pid " + stringify(pid) + " to cgroup at "
+        "'" + path::join(hierarchy, infos[containerId]->cgroup) + "'"
+        ": " + assign.error();
+
+      LOG(ERROR) << message;
+
+      return Failure(message);
+    }
+  }
+
+  list<Future<Nothing>> isolates;
+  foreachvalue (const Owned<Subsystem>& subsystem, subsystems) {
+    isolates.push_back(subsystem->isolate(containerId, pid));
+  }
+
+  return collect(isolates).then([]() { return Nothing(); });
 }