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

cgroup2: Manager.Delete: handle both "threaded" and "domain threaded" #358

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

thaJeztah
Copy link
Member

commit 6f5001d added special handling for threaded cgroup types. A later contribution added detection for "domain threaded" as known type, but did not update the handling to detect this type.

From the original PR;

Reading cgroup.procs seems to return ENOTSUPP when threaded, so check
the type of the cg when going to delete and read the relevant file.

An alternative could be to check both variants unconditionally, and to error if either Manager.Threads or Manager.Procs is non-zero.

commit 6f5001d added special handling
for threaded cgroup types. A later contribution added detection for
"domain threaded" as known type, but did not update the handling to
detect this type.

From the original PR;

> Reading cgroup.procs seems to return ENOTSUPP when threaded, so check
> the type of the cg when going to delete and read the relevant file.

An alternative could be to check both variants unconditionally, and to
error if either Manager.Threads or Manager.Procs is non-zero.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Comment on lines +488 to 491
case Threaded, DomainThreaded:
tasks, err = c.Threads(true)
} else {
default:
tasks, err = c.Procs(true)
Copy link
Member Author

Choose a reason for hiding this comment

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

Alternative could be to just to try either if we get anything in return?

if tasks, _ := c.Threads(true); len(tasks) > 0 {
	return fmt.Errorf("cgroups: unable to remove path %q: still contains running tasks", c.path)
}
if tasks, _ := c.Procs(true); len(tasks) > 0 {
	return fmt.Errorf("cgroups: unable to remove path %q: still contains running tasks", c.path)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, not sure if that makes sense. Looking at Procs and Threads, they both call getTasks under the hood; if the above does make sense, I guess that function could possibly accept both cgroupProcs and cgroupThreads to get "any".

@thaJeztah thaJeztah requested a review from dmcgowan December 15, 2024 00:42
@fuweid fuweid merged commit bce3c7e into containerd:main Dec 17, 2024
8 checks passed
@thaJeztah thaJeztah deleted the handle_domain_threaded branch December 17, 2024 07:45
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 this pull request may close these issues.

3 participants