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

/proc/self/cgroup does not contain relative paths in docker container #34584

Open
tmds opened this issue Aug 21, 2017 · 0 comments
Open

/proc/self/cgroup does not contain relative paths in docker container #34584

tmds opened this issue Aug 21, 2017 · 0 comments

Comments

@tmds
Copy link

tmds commented Aug 21, 2017

Description

/proc/self/cgroup does not contain relative paths in docker container.

man cgroups describes this file should contain relative paths:

This field contains the pathname of the control group in
the hierarchy to which the process belongs. This pathname
is relative to the mount point of the hierarchy.

And so does man cgroup_namespaces:

When viewing /proc/[pid]/cgroup, the pathname shown in the third
field of each record will be relative to the reading process's root
directory for the corresponding cgroup hierarchy.

Steps to reproduce the issue:

For example, in a docker container

/proc/self/mountinfo:
396 394 0:21 /kubepods/besteffort/pod9a18ffb8-8513-11e7-b26e-7e29fbe2a5a3/d28e0087cf8f3f0429f755d60b0de415b20fcf76736ded7bab6e30e7b739ee36 /sys/fs/cgroup/cpu ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu
/proc/self/cgroup:
2:cpu:/kubepods/besteffort/pod9a18ffb8-8513-11e7-b26e-7e29fbe2a5a3/d28e0087cf8f3f0429f755d60b0de415b20fcf76736ded7bab6e30e7b739ee36

The path in the cgroup file is not a relative path but it matches the mount root. The limits are not found at that path under the mount point, but directly under the mount point:

$ ls /sys/fs/cgroup/cpu                                                                                                                                                                                                             
cgroup.clone_children  cgroup.procs  cpu.cfs_period_us  cpu.cfs_quota_us  cpu.rt_period_us  cpu.rt_runtime_us  cpu.shares  cpu.stat  notify_on_release  tasks

Expected behavior:

/proc/self/cgroup to behave as described in the man pages.
Or document the difference in the docker docs.

mook-as added a commit to mook-as/guardian that referenced this issue Feb 28, 2018
This is, basically, a workaround for moby/moby#34584
When creating cgroup directories, check that our cgroup mountpoint isn't
itself a child cgroup; if it is, adjust the paths accordingly so that
the paths (relative to the top cgroup) is correct.  Otherwise we end up
with cgroups that have duplicate sections in the path.
mook-as added a commit to mook-as/guardian that referenced this issue Feb 28, 2018
This is, basically, a workaround for moby/moby#34584
When creating cgroup directories, check that our cgroup mountpoint isn't
itself a child cgroup; if it is, adjust the paths accordingly so that
the paths (relative to the top cgroup) is correct.  Otherwise we end up
with cgroups that have duplicate sections in the path.
mook-as added a commit to mook-as/guardian that referenced this issue Mar 2, 2018
This is, basically, a workaround for moby/moby#34584
When creating cgroup directories, check that our cgroup mountpoint isn't
itself a child cgroup; if it is, adjust the paths accordingly so that
the paths (relative to the top cgroup) is correct.  Otherwise we end up
with cgroups that have duplicate sections in the path.
mook-as added a commit to SUSE/scf that referenced this issue Apr 23, 2018
Set up hostpath mounts to /sys/fs/cgroups on diego-cell so that garden
can correctly create cgroups at the global level (because docker doesn't
isolate things correctly).  This fixes issues with memory accounting in
the Kubernetes dashboard.

See:
- #1345
- cloudfoundry/guardian#110
- moby/moby#34584
mook-as added a commit to SUSE/scf that referenced this issue Apr 27, 2018
Set up hostpath mounts to /sys/fs/cgroups on diego-cell so that garden
can correctly create cgroups at the global level (because docker doesn't
isolate things correctly).  This fixes issues with memory accounting in
the Kubernetes dashboard.

See:
- #1345
- cloudfoundry/guardian#110
- moby/moby#34584
jhnwkmn added a commit to mariadb-corporation/MaxScale that referenced this issue Sep 20, 2022
/proc/self/cgroup does not contain relative paths in docker container

moby/moby#34584
jhnwkmn added a commit to mariadb-corporation/MaxScale that referenced this issue Sep 22, 2022
/proc/self/cgroup does not contain relative paths in docker container

moby/moby#34584
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants