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

Allow rootless buildah to set resource limits on cgroup V2 #3594

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Oct 21, 2021

First move podman/pkg/cgroups into Buildah.
Only set resources to nil on non cgroupsv2 systems in rootless mode.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

What type of PR is this?

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?


@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 21, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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

@rhatdan
Copy link
Member Author

rhatdan commented Oct 21, 2021

@nalind @giuseppe This seems to work, but Buildah is getting a different cgroupfs mounted then Podman.
Podman is getting

$ podman run -ti alpine ls -1 /sys/fs/cgroup/
cgroup.controllers
cgroup.events
cgroup.freeze
cgroup.kill
cgroup.max.depth
cgroup.max.descendants
cgroup.procs
cgroup.stat
cgroup.subtree_control
cgroup.threads
cgroup.type
cpu.max
cpu.max.burst
cpu.pressure
cpu.stat
cpu.weight
cpu.weight.nice
io.bfq.weight
io.latency
io.max
io.pressure
io.prio.class
io.stat
io.weight
memory.current
memory.events
memory.events.local
memory.high
memory.low
memory.max
memory.min
memory.numa_stat
memory.oom.group
memory.pressure
memory.stat
memory.swap.current
memory.swap.events
memory.swap.high
memory.swap.max
pids.current
pids.events
pids.max

But Buildah sees

STEP 3/3: RUN ls /sys/fs/cgroup/
cgroup.controllers
cgroup.max.depth
cgroup.max.descendants
cgroup.procs
cgroup.stat
cgroup.subtree_control
cgroup.threads
cpu.pressure
cpu.stat
cpuset.cpus.effective
cpuset.mems.effective
dev-hugepages.mount
dev-mqueue.mount
init.scope
io.cost.model
io.cost.qos
io.pressure
io.prio.class
io.stat
machine.slice
memory.numa_stat
memory.pressure
memory.stat
misc.capacity
sys-fs-fuse-connections.mount
sys-kernel-config.mount
sys-kernel-debug.mount
sys-kernel-tracing.mount
system.slice
user.slice

Any idea what I am doing wrong?
Tests are looking for /sys/fs/cgroup/cpu.max

@giuseppe
Copy link
Member

giuseppe commented Nov 3, 2021

Any idea what I am doing wrong?

are you adding a cgroupns to the container?

With cgroupv2 we do that by default, while on cgroupv1 by default it is --cgroupns=host

@rhatdan
Copy link
Member Author

rhatdan commented Nov 4, 2021

Ok it looks like buildah does not do anything with cgroupns. We need to add that support.
@giuseppe could you take this PR over and add cgroupns, or I will get to it when I have some time.

@giuseppe
Copy link
Member

giuseppe commented Nov 4, 2021

I've looked and we already use a cgroupns. I think we are hitting: containers/crun#765

@rhatdan
Copy link
Member Author

rhatdan commented Nov 4, 2021

Do we have a new crun release?

@giuseppe
Copy link
Member

giuseppe commented Nov 4, 2021

I'll work on a new one now, I need to fix the CI first :/

I've also found another issue in Buildah while debugging this PR: #3614

@giuseppe
Copy link
Member

giuseppe commented Nov 4, 2021

Do we have a new crun release?

tagging one: containers/crun#770

@giuseppe
Copy link
Member

giuseppe commented Nov 5, 2021

the new builds are on Bodhi

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 1, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 1, 2021
@rhatdan rhatdan changed the title Allow rootless buildah to set resource limits on cgroup V2 [wip] Allow rootless buildah to set resource limits on cgroup V2 Dec 3, 2021
@rhatdan rhatdan force-pushed the group branch 2 times, most recently from d2bf90d to ed556f0 Compare December 3, 2021 18:54
@rhatdan rhatdan changed the title [wip] Allow rootless buildah to set resource limits on cgroup V2 Allow rootless buildah to set resource limits on cgroup V2 Dec 3, 2021
@rhatdan
Copy link
Member Author

rhatdan commented Dec 10, 2021

Verifying containers/common#854

@rhatdan rhatdan changed the title Allow rootless buildah to set resource limits on cgroup V2 [wip] Allow rootless buildah to set resource limits on cgroup V2 Dec 10, 2021
@rhatdan
Copy link
Member Author

rhatdan commented Dec 13, 2021

@vrothberg Latest containers/common filters patch is passing here now.

@rhatdan rhatdan changed the title [wip] Allow rootless buildah to set resource limits on cgroup V2 Allow rootless buildah to set resource limits on cgroup V2 Dec 14, 2021
@rhatdan
Copy link
Member Author

rhatdan commented Dec 14, 2021

@nalind @giuseppe @flouthoc @vrothberg @TomSweeneyRedHat @umohnani8 This is ready to review.

@umohnani8
Copy link
Member

LGTM

DefaultAction Action `json:"defaultAction"`
DefaultAction Action `json:"defaultAction"`

// DefaultErrnoRet is obsolete, please use DefaultErrno
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 need to update our seccomp handling in chroot to account for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@giuseppe PTAL

@@ -61,7 +63,8 @@ func (r *Runtime) Import(ctx context.Context, path string, options *ImportOption
u, err := url.ParseRequestURI(path)
if err == nil && u.Scheme != "" {
// If source is a URL, download the file.
file, err := r.downloadFromURL(path)
fmt.Printf("Downloading from %q\n", path)
Copy link
Member

Choose a reason for hiding this comment

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

Is this a bug?

Copy link
Member Author

Choose a reason for hiding this comment

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

@vrothberg PTAL

Copy link
Member

Choose a reason for hiding this comment

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

It's preserving previous behavior, see containers/common@2f3c4bcdfdcf. But I am for changing the behavior. Libraries should not print on stdout.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well that should happen in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, that's what I also wrote in the PR of containers/common@2f3c4bcdfdcf. It may require changes to Podman to preserve behavior but I did not investigate.

First move podman/pkg/cgroups into Buildah.
Only set resources to nil on non cgroupsv2 systems in rootless mode.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@TomSweeneyRedHat
Copy link
Member

The changes in here LGTM. Are we holding this for an update to common to fix the printf and/or updates to Podman?

@rhatdan rhatdan added the lgtm label Dec 14, 2021
@openshift-merge-robot openshift-merge-robot merged commit 857ba5a into containers:main Dec 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants