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

cgroups: kill processes when deleting a cgroup #1019

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented May 3, 2022

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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 3, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@vrothberg vrothberg left a 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
}
Copy link
Member

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 gofmted is it? The indentation looks off.

Copy link
Member Author

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
$

@rhatdan
Copy link
Member

rhatdan commented May 3, 2022

LGTM
Do we want this in podman 4.1?

@@ -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 {
Copy link
Collaborator

@flouthoc flouthoc May 3, 2022

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

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amended the change

Copy link
Collaborator

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

@giuseppe
Copy link
Member Author

giuseppe commented May 3, 2022

LGTM Do we want this in podman 4.1?

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>
@giuseppe giuseppe force-pushed the kill-processes-cgroup-cleanup branch from 0d91c25 to 6c02139 Compare May 3, 2022 10:48
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 3, 2022
@openshift-merge-robot openshift-merge-robot merged commit 3c23ef2 into containers:main May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants