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
cgroups: kill processes when deleting a cgroup #1019
cgroups: kill processes when deleting a cgroup #1019
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Nice idea!
@@ -118,8 +130,16 @@ func rmDirRecursively(path string) error { | |||
return 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.
The file doesn't look gofmt
ed is it? The indentation looks off.
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.
gofmt
seems happy about it:
$ gofmt -l pkg/cgroups/cgroups_supported.go
$
LGTM |
@@ -96,6 +97,17 @@ func UserOwnsCurrentSystemdCgroup() (bool, error) { | |||
// It differs from os.RemoveAll as it doesn't attempt to unlink files. | |||
// On cgroupfs we are allowed only to rmdir empty directories. | |||
func rmDirRecursively(path string) error { | |||
killProcesses := func(signal syscall.Signal) { | |||
// kill all the processes that are still part of the cgroup | |||
if procs, err := ioutil.ReadFile(filepath.Join(path, "cgroup.procs")); 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.
@giuseppe Could we utitlise cgroup.kill
if available
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.
we could for SIGKILL, but we will still need the code for SIGTERM
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.
amended the change
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.
Thanks looks good to me, do we need to check if kernel
is above 5.14+
before using cgroup.kill
not sure it is so important to hurry it up in a release, it solves a race condition that I was never able to reproduce locally |
if the cgroup cleanup fails with EBUSY, attempt to kill the processes. Related to: containers/podman#14057 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
0d91c25
to
6c02139
Compare
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
if the cgroup cleanup fails with EBUSY, attempt to kill the
processes.
Related to: containers/podman#14057
Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com