-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[1.0] Remove sub cgroup when container exits #3297
Conversation
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 <kongchen28@gmail.com> [kolyshkin: cherry picked from commit 7758d3f, changing the code to use cgroups.RemovePath().] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// XXX this is probably not needed, systemd should handle it | ||
err := os.Remove(m.path) | ||
if err != nil && !os.IsNotExist(err) { | ||
// systemd 239 do not remove sub-cgroups. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// systemd 239 do not remove sub-cgroups. | |
// systemd 239 does not remove sub-cgroups. |
err := cgroups.RemovePath(m.path) | ||
// cgroups.RemovePath has handled ErrNotExist | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.. didn't notice this when reviewing #3226 but, given that this is the last code of the function, looks like we could just return cgroups.RemovePath(m.path)
here.
No need to change, as this more closely matches what's in main
(but we could clean that up)
(I see you also requested a review from @cyphar, but feel free to merge if that was just "one of you both" 😅) |
Both suggestions from @thaJeztah are valid, I guess it makes sense to fix them in main branch. Here, not so much, as this is a release branch that will be hopefully be closed some time after we release 1.1. |
This is a backport of #3226 to release-1.0 branch, fixing issue #3225.
Note it's not a clean backport as 1.0 lacks fsMgr field, and we do not want to instantiate one, so the commit was changed:
Proposed changelog entry