DevinLeamy commented on code in PR #556:
URL: https://github.com/apache/mesos/pull/556#discussion_r1569562534


##########
src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp:
##########
@@ -120,6 +144,569 @@ bool Cgroups2IsolatorProcess::supportsStandalone()
   return true;
 }
 
+
+Future<Option<ContainerLaunchInfo>> Cgroups2IsolatorProcess::prepare(
+    const ContainerID& containerId,
+    const ContainerConfig& containerConfig)
+{
+  if (containerId.has_parent()) {
+    return Failure("cgroups v2 does not support nested containers");
+  }
+
+  if (infos.contains(containerId)) {
+    return Failure(
+        "Container with id '" + stringify(containerId) + "' "
+        "has already been prepared");
+  }
+
+  CHECK(containerConfig.container_class() != ContainerClass::DEBUG);
+
+  // Create the non-leaf and leaf cgroups for the container, enable
+  // controllers in the non-leaf cgroup, and `prepare` each of the controllers.
+  const string& cgroup = cgroups2_paths::container(
+      flags.cgroups_root, containerId);
+  if (cgroups2::exists(cgroup)) {
+    return Failure("Cgroup '" + cgroup + "' already exists");
+  }
+
+  Try<Nothing> createCgroup = cgroups2::create(cgroup);
+  if (createCgroup.isError()) {
+    return Failure("Failed to create cgroup '" + cgroup + "': "
+                   + createCgroup.error());
+  }
+
+  const string& leafCgroup = cgroups2_paths::container(
+      flags.cgroups_root, containerId, true);
+  if (cgroups2::exists(leafCgroup)) {
+    return Failure("Cgroup '" + leafCgroup + "' already exists");
+  }
+
+  Try<Nothing> createLeafCgroup = cgroups2::create(leafCgroup);
+  if (createLeafCgroup.isError()) {
+    return Failure("Failed to create cgroup '" + leafCgroup + "': "
+                   + createLeafCgroup.error());
+  }
+
+  LOG(INFO) << "Created cgroups '" << cgroup << "' and '" << leafCgroup << "'";
+
+  infos[containerId] = Owned<Info>(new Info(containerId, cgroup));
+  vector<Future<Nothing>> prepares;
+  foreachvalue (const Owned<Controller>& controller, controllers) {
+    // Enable controllers in the non-leaf cgroup.
+    Try<Nothing> enable =
+      cgroups2::controllers::enable(cgroup, {controller->name()});

Review Comment:
   Enable the controllers in the leaf controllers so that containers have the 
ability to manage their own resources and/or enable controllers in sub cgroups. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to