Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroup v1 take into account mount root #237

Merged
merged 3 commits into from
May 2, 2024
Merged

cgroup v1 take into account mount root #237

merged 3 commits into from
May 2, 2024

Conversation

glipner
Copy link
Contributor

@glipner glipner commented May 1, 2024

In a machine with Cgroups V1, by default Docker doesn't enter a cgroup namespace (--cgroupns=host).
Inside the container, as subtree of the host cgroup hierarchy is mounted:

# cat /proc/1/mountinfo
712 709 0:34 /docker/<guid> /sys/fs/cgroup/cpu,cpuacct ro,nosuid,nodev,noexec,relatime master:16 - cgroup cgroup rw,cpu,cpuacct

Meaning that accessing /sys/fs/cgroup/<controller>/something inside the container is the same as accessing /sys/fs/cgroup/<controller>/docker/<guid>/something from the host.

Reading from /proc/pid/cgroup yields a path in the host mount:
3:cpu,cpuacct:/docker/<guid>.
To access this cgroup from within the container, we need to strtip the /docker/<guid> part.

@glipner glipner requested a review from mirikl May 1, 2024 21:30
@glipner glipner self-assigned this May 1, 2024
@glipner glipner requested a review from d3dave May 2, 2024 05:18
@glipner glipner merged commit 96d1d84 into master May 2, 2024
7 checks passed
@glipner glipner deleted the cgroup_bugfix branch May 2, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants