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: v2 should use kill interface instead of freezer #14371

Closed
shoenig opened this issue Aug 29, 2022 · 1 comment · Fixed by #14385
Closed

cgroups: v2 should use kill interface instead of freezer #14371

shoenig opened this issue Aug 29, 2022 · 1 comment · Fixed by #14385
Assignees

Comments

@shoenig
Copy link
Member

shoenig commented Aug 29, 2022

When implementing support for cgroups v2 we mostly tried to keep the v1 logic but retrofit it onto v2. This includes the block of code for forcefully killing processes related to a task https://github.com/hashicorp/nomad/blob/v1.3.4/client/lib/cgutil/group_killer.go#L98

In v2, there is now the cgroup.kill interface file, which we can simply write a 1 into to kill all processes present in the cgroup (i.e. show up in cgroup.procs). Unlike cgroup.freeze, cgroup.kill handles racy forkers.

Writing “1” to the file causes the cgroup and all descendant cgroups to be killed. This means that all processes located in the affected cgroup tree will be killed via SIGKILL.

Killing a cgroup tree will deal with concurrent forks appropriately and is protected against migrations.
@shoenig shoenig self-assigned this Aug 29, 2022
shoenig added a commit that referenced this issue Aug 29, 2022
This PR refactors the cgroups v2 group kill code path to use the
cgroups.kill interface file for destroying the cgroup. Previously
we copied the freeze + sigkill + unfreeze pattern from the v1 code,
but v2 provides a more efficient and more race-free way to handle
this.

Closes #14371
shoenig added a commit that referenced this issue Aug 30, 2022
This PR refactors the cgroups v2 group kill code path to use the
cgroups.kill interface file for destroying the cgroup. Previously
we copied the freeze + sigkill + unfreeze pattern from the v1 code,
but v2 provides a more efficient and more race-free way to handle
this.

Closes #14371
shoenig added a commit that referenced this issue Aug 30, 2022
This PR refactors the cgroups v2 group kill code path to use the
cgroups.kill interface file for destroying the cgroup. Previously
we copied the freeze + sigkill + unfreeze pattern from the v1 code,
but v2 provides a more efficient and more race-free way to handle
this.

Closes #14371
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant