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

rootless: allow resource isolation with cgroup v2 #3104

Merged
merged 3 commits into from
May 17, 2019

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented May 10, 2019

this is not adding any support for cgroup v2. It is only used to avoid some early errors when attempting to use cgroup v2 for rootless users.

Depends on:

with the updated versions of conmon and crun, on a Fedora 30 configured with cgroup v2 unified mode, I can:

$ podman --runtime /usr/bin/crun run --memory=100M \
   --rm fedora sh -c 'cat $(cat /proc/self/cgroup | sed -e"s|0::|/sys/fs/cgroup|")/memory.max'
 104857600


@openshift-ci-robot
Copy link
Collaborator

[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

@openshift-ci-robot openshift-ci-robot requested review from baude and mheon May 10, 2019 16:29
@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S labels May 10, 2019
@giuseppe
Copy link
Member Author

/cc @mheon @AkihiroSuda

@openshift-ci-robot
Copy link
Collaborator

@giuseppe: GitHub didn't allow me to request PR reviews from the following users: AkihiroSuda.

Note that only containers members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @mheon @AkihiroSuda

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -76,6 +77,17 @@ func addWarning(warnings []string, msg string) []string {

func verifyContainerResources(config *cc.CreateConfig, update bool) ([]string, error) {
warnings := []string{}

var st syscall.Statfs_t
if err := syscall.Statfs("/sys/fs/cgroup", &st); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can we either do this once and stick it in a bool we can read, or make a helper for the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, good idea. Done in the new version

const _CGROUP2_SUPER_MAGIC = 0x63677270

// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 unified mode.
func IsCgroup2UnifiedMode() (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you put this into buildah rather then into Podman so both tools can share the check?

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 are not currently doing any the same check in Buildah as we do for Podman when resources are specified.

@giuseppe
Copy link
Member Author

correction: it works fine on Fedora 30 with the systemd version available there.

giuseppe added 3 commits May 13, 2019 10:48
We were always raising an error when the rootless user attempted to
setup resources, but this is not the case anymore with cgroup v2.

Signed-off-by: Giuseppe Scrivano <[email protected]>
skip resources validation when cgroup v2 is detected, as we don't
support it yet.

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe
Copy link
Member Author

tests are finally passing

@mheon
Copy link
Member

mheon commented May 13, 2019

Question: does this break runc rootless containers on CGroupsV2 enabled systems?

@giuseppe
Copy link
Member Author

Question: does this break runc rootless containers on CGroupsV2 enabled systems?

the only difference for rootless Podman with runc will be that if an user specifies any resource, Podman won't error out immediately but it will let the runtime handle it. I've not tried it but I'd expect it to fail on cgroup v2 also when resources are not specified

@giuseppe
Copy link
Member Author

the change for conmon got merged, fine to merge this?

@mheon
Copy link
Member

mheon commented May 17, 2019

LGTM

@rhatdan
Copy link
Member

rhatdan commented May 17, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 17, 2019
@openshift-merge-robot openshift-merge-robot merged commit 144244a into containers:master May 17, 2019
@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 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 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.

5 participants