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

When rootless runc exits, failed to remove cgroupv2 with sub-cgroup #3225

Closed
chenk008 opened this issue Sep 27, 2021 · 2 comments · Fixed by #3226
Closed

When rootless runc exits, failed to remove cgroupv2 with sub-cgroup #3225

chenk008 opened this issue Sep 27, 2021 · 2 comments · Fixed by #3226

Comments

@chenk008
Copy link
Contributor

chenk008 commented Sep 27, 2021

In case of rootless, cgroup2 mount into container /sys/fs/cgroup. After I created sub-cgroup test, and then exited. A error message shown

ERRO[0029] remove /sys/fs/cgroup/user.slice/user-1000.slice/[email protected]/user.slice/runc-foo.scope: device or resource busy

Reproduce:

runc spec --rootless
// add cgroupfs mount into config.json
{
      "destination": "/sys/fs/cgroup",
      "type": "cgroup",
      "source": "cgroup",
      "options": [
        "nosuid",
        "noexec",
        "nodev",
        "relatime"
      ]
}
runc --systemd-cgroup run foo
// in the container
mkdir /sys/fs/cgroup/test
exit

systemd version: 239 (239-41.el8_3)
kernel version: 4.18.0-305.12.1.el8_4.x86_64
linux distro: centos 8

@chenk008
Copy link
Contributor Author

I think it relates to

err := os.Remove(m.path)

@kolyshkin
Copy link
Contributor

Ah, so you're using cgroup v2 on CentOS 8. We do not test this configuration, this is why we do not catch this bug.

chenk008 pushed a commit to chenk008/runc that referenced this issue Sep 29, 2021
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers#3225

Signed-off-by: Kang Chen <[email protected]>
chenk008 added a commit to chenk008/runc that referenced this issue Oct 1, 2021
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers#3225

Signed-off-by: Kang Chen <[email protected]>
chenk008 added a commit to chenk008/runc that referenced this issue Oct 1, 2021
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers#3225

Signed-off-by: Kang Chen <[email protected]>
kolyshkin pushed a commit to kolyshkin/runc that referenced this issue Nov 29, 2021
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers#3225

Signed-off-by: Kang Chen <[email protected]>
(cherry picked from commit 7758d3f)
Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin pushed a commit to kolyshkin/runc that referenced this issue Nov 30, 2021
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers#3225

Signed-off-by: Kang Chen <[email protected]>

[kolyshkin: cherry picked from commit 7758d3f,
 changing the code to use cgroups.RemovePath().]

Signed-off-by: Kir Kolyshkin <[email protected]>
dims pushed a commit to dims/libcontainer that referenced this issue Oct 19, 2024
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers/runc#3225

Signed-off-by: Kang Chen <[email protected]>
dims pushed a commit to dims/libcontainer that referenced this issue Oct 19, 2024
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers/runc#3225

Signed-off-by: Kang Chen <[email protected]>
dims pushed a commit to dims/libcontainer that referenced this issue Oct 19, 2024
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers/runc#3225

Signed-off-by: Kang Chen <[email protected]>
kolyshkin pushed a commit to kolyshkin/containerd-cgroups that referenced this issue Nov 6, 2024
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8.
But after the container exited, the container cgroup and its subcgroup will not be removed.

Fix this by removing all directories recursively.

Fixes: opencontainers/runc#3225

Signed-off-by: Kang Chen <[email protected]>
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 a pull request may close this issue.

2 participants