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 2014/06/27 20:14:20 UTC
git commit: Enabled the support for creating nested cgroup
structures. This is important for systemd support.
Repository: mesos
Updated Branches:
refs/heads/master b523da556 -> 24ebd1ba8
Enabled the support for creating nested cgroup structures. This is
important for systemd support.
Review: https://reviews.apache.org/r/22977
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/24ebd1ba
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/24ebd1ba
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/24ebd1ba
Branch: refs/heads/master
Commit: 24ebd1ba8bdf783aeeb72b20ef2bd9e894244e12
Parents: b523da5
Author: Timothy St. Clair <ts...@redhat.com>
Authored: Fri Jun 27 11:13:43 2014 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jun 27 11:13:43 2014 -0700
----------------------------------------------------------------------
src/linux/cgroups.cpp | 21 +++++++++++++--------
src/linux/cgroups.hpp | 10 ++++++----
2 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/24ebd1ba/src/linux/cgroups.cpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.cpp b/src/linux/cgroups.cpp
index 5472eb8..0a6c76f 100644
--- a/src/linux/cgroups.cpp
+++ b/src/linux/cgroups.cpp
@@ -270,17 +270,19 @@ static Try<Nothing> cloneCpusetCpusMems(
// given cgroup is a relative path to the given hierarchy. This
// function assumes the given hierarchy is valid and is currently
// mounted with a cgroup virtual file system. The function also
-// assumes the given cgroup is valid. This function will not create
-// directories recursively, which means it will return error if any of
-// the parent cgroups do not exist.
+// assumes the given cgroup is valid.
// @param hierarchy Path to the hierarchy root.
// @param cgroup Path to the cgroup relative to the hierarchy root.
+// @param recursive Create nest cgroup structure
// @return Some if the operation succeeds.
// Error if the operation fails.
-static Try<Nothing> create(const string& hierarchy, const string& cgroup)
+static Try<Nothing> create(
+ const string& hierarchy,
+ const string& cgroup,
+ bool recursive)
{
string path = path::join(hierarchy, cgroup);
- Try<Nothing> mkdir = os::mkdir(path, false); // Do NOT create recursively.
+ Try<Nothing> mkdir = os::mkdir(path, recursive);
if (mkdir.isError()) {
return Error(
"Failed to create directory '" + path + "': " + mkdir.error());
@@ -487,7 +489,7 @@ Try<string> prepare(
if (!exists.get()) {
// No cgroup exists, create it.
- Try<Nothing> create = cgroups::create(hierarchy, cgroup);
+ Try<Nothing> create = cgroups::create(hierarchy, cgroup, true);
if (create.isError()) {
return Error("Failed to create root cgroup " +
path::join(hierarchy, cgroup) +
@@ -834,14 +836,17 @@ Try<bool> mounted(const string& hierarchy, const string& subsystems)
}
-Try<Nothing> create(const string& hierarchy, const string& cgroup)
+Try<Nothing> create(
+ const string& hierarchy,
+ const string& cgroup,
+ bool recursive)
{
Option<Error> error = verify(hierarchy);
if (error.isSome()) {
return error.get();
}
- return internal::create(hierarchy, cgroup);
+ return internal::create(hierarchy, cgroup, recursive);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/24ebd1ba/src/linux/cgroups.hpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.hpp b/src/linux/cgroups.hpp
index eba4cdf..decad9d 100644
--- a/src/linux/cgroups.hpp
+++ b/src/linux/cgroups.hpp
@@ -175,14 +175,16 @@ Try<bool> mounted(
// Create a cgroup under a given hierarchy. This function will return error if
-// the given hierarchy is not valid. The cgroup will NOT be created recursively.
-// In other words, if the parent cgroup does not exist, this function will just
-// return error.
+// the given hierarchy is not valid.
// @param hierarchy Path to the hierarchy root.
// @param cgroup Path to the cgroup relative to the hierarchy root.
+// @param recursive Will create nested cgroups
// @return Some if the operation succeeds.
// Error if the operation fails.
-Try<Nothing> create(const std::string& hierarchy, const std::string& cgroup);
+Try<Nothing> create(
+ const std::string& hierarchy,
+ const std::string& cgroup,
+ bool recursive = false);
// Remove a cgroup under a given hierarchy. This function will return error if