This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new 2d22c120f [cgroups2] Collect process & thread from leaf groups.
2d22c120f is described below
commit 2d22c120f3585c993d03182f19c56c31ccb8318d
Author: Jason Zhou <[email protected]>
AuthorDate: Fri Aug 9 18:02:11 2024 -0400
[cgroups2] Collect process & thread from leaf groups.
Currently, our core controller usage() function try to read the cgroup
files in the argument cgroup. However, in our design for cgroups v2,
processes and threads live in the leaf child of a cgroup. Hence the
usage collection will not find the actual processes and threads for a
cgroup if it's not already specified as a leaf group.
This patch adds a check to see if the argument cgroup is a leaf cgroup,
and will search for processes and threads in the leaf cgroup instead.
Review: https://reviews.apache.org/r/75158/
---
.../mesos/isolators/cgroups2/controllers/core.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git
a/src/slave/containerizer/mesos/isolators/cgroups2/controllers/core.cpp
b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/core.cpp
index 54d7c8977..051f4939e 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups2/controllers/core.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/core.cpp
@@ -60,14 +60,21 @@ process::Future<ResourceStatistics>
CoreControllerProcess::usage(
ResourceStatistics stats;
if (flags.cgroups_cpu_enable_pids_and_tids_count) {
- Try<set<pid_t>> pids = cgroups2::processes(cgroup);
+ // In cgroups v2 we store our processes and threads in a leaf child, so we
+ // look at the leaf child of the cgroup if the provided cgroup isn't a leaf
+ // child.
+ string target = strings::endsWith(strings::trim(cgroup, "/"), "leaf")
+ ? strings::trim(cgroup, "/")
+ : path::join(cgroup, "leaf");
+
+ Try<set<pid_t>> pids = cgroups2::processes(target);
if (pids.isError()) {
return Failure("Failed to get processes in cgroup: " + pids.error());
}
stats.set_processes(pids->size());
- Try<set<pid_t>> tids = cgroups2::threads(cgroup);
+ Try<set<pid_t>> tids = cgroups2::threads(target);
if (tids.isError()) {
return Failure("Failed to get threads in cgroup: " + tids.error());
}