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

cgroup: always honor --cgroup-parent #10177

Merged

Conversation

giuseppe
Copy link
Member

if --cgroup-parent is specified, always honor it without doing any
detection whether cgroups are supported or not.

Closes: #10173

Signed-off-by: Giuseppe Scrivano [email protected]

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 29, 2021
@@ -2224,12 +2224,11 @@ func (c *Container) getOCICgroupPath() (string, error) {
}
cgroupManager := c.CgroupManager()
switch {
case c.config.CgroupParent != "":
Copy link
Member

Choose a reason for hiding this comment

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

I think we should avoid this for the systemd cgroup manager

@giuseppe giuseppe force-pushed the always-honor-cgroup-parent branch 8 times, most recently from 1db5d2c to a69caee Compare April 30, 2021 15:21
@giuseppe
Copy link
Member Author

green tests

@@ -2225,7 +2225,7 @@ func (c *Container) getOCICgroupPath() (string, error) {
cgroupManager := c.CgroupManager()
switch {
case (rootless.IsRootless() && (cgroupManager == config.CgroupfsCgroupsManager || !unified)) || c.config.NoCgroups:
return "", nil
return c.config.CgroupParent, nil
Copy link
Member

Choose a reason for hiding this comment

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

Do we risk breaking existing rootless containers that have CgroupParent set to the default?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point.

Not sure what is the best way to deal with it. Should we stop setting it if it is the default value (perhaps until podman 4.x)?

Copy link
Member

Choose a reason for hiding this comment

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

Is there any way we can do an access check on the cgroup, see if we have the ability to use it without error? If not, then your suggestion is definitely the best way forward.

Copy link
Member Author

@giuseppe giuseppe May 3, 2021

Choose a reason for hiding this comment

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

I think that will be error prone and difficult to get right. We won't only have to check if the current user has permissions to the cgroup, but that any ID mapped in the user namespace has it. And that will be even more complicated with cgroup v1.

Looking more into it, I don't think it will be a problem if we just check for c.config.CgroupParent == CgroupfsDefaultCgroupParent as that cgroup is usually owned by root.

What do you think about the new version?

EDIT: we don't really need to check for IDs mapped in the user namespace, since the cgroup is not configured from the container user namespace (if it has any)

Copy link
Member

Choose a reason for hiding this comment

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

Alright, this SGTM

@giuseppe giuseppe force-pushed the always-honor-cgroup-parent branch 4 times, most recently from bb109c3 to 3fcdb90 Compare May 3, 2021 10:28
if --cgroup-parent is specified, always honor it without doing any
detection whether cgroups are supported or not.

Closes: containers#10173

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the always-honor-cgroup-parent branch from 3fcdb90 to 17ce567 Compare May 3, 2021 10:36
@mheon
Copy link
Member

mheon commented May 3, 2021

LGTM
@containers/podman-maintainers PTAL

@rhatdan
Copy link
Member

rhatdan commented May 3, 2021

/approve
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 3, 2021
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, rhatdan

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

@openshift-merge-robot openshift-merge-robot merged commit 24156f9 into containers:master May 3, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--cgroup-parent has no effect
5 participants