Skip to content

Add ulimits to podman update #26445

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aaron-ang
Copy link

@aaron-ang aaron-ang commented Jun 17, 2025

Fixes #26381

Does this PR introduce a user-facing change?

Added `--ulimit` flag to `podman update` allowing users to edit container ulimits.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note labels Jun 17, 2025
Copy link
Contributor

openshift-ci bot commented Jun 17, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aaron-ang
Once this PR has been reviewed and has the lgtm label, please assign tomsweeneyredhat for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Jun 17, 2025
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

2 similar comments
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@Honny1
Copy link
Member

Honny1 commented Jun 17, 2025

Hi, I did a quick code check. And you need to move this definition of the ulimit flag to this if statement.

@Luap99
Copy link
Member

Luap99 commented Jun 17, 2025

The commit needs a sign off, see https://github.com/containers/podman/blob/main/CONTRIBUTING.md#sign-your-prs

Also please add the Fixes: #xxx line to your commit message as well.

# bats test_tags=distro-integration
@test "podman update - test all options" {
local cgv=1
if is_cgroupsv2; then
cgv=2;
cgv=2
Copy link
Member

Choose a reason for hiding this comment

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

please don't change the formatting of unrelated parts of this file.

Copy link
Member

Choose a reason for hiding this comment

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

@Luap99 does this apply to subsequent formatting changes too?

Copy link
Member

Choose a reason for hiding this comment

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

yes everything that is not related to this specific new test should not be touched as it will make git blame much harder to use.

(Now if anybody has opinions abut using a consistent formatter they can voice their arguments here #26340)

Copy link
Author

Choose a reason for hiding this comment

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

reverted the changes

@@ -306,4 +306,65 @@ var _ = Describe("Podman update", func() {
Expect(env).ToNot(ContainSubstring("FOO"))
Expect(env).To(ContainSubstring("PATH="))
})

It("podman update sets ulimits", func() {
session := podmanTest.Podman([]string{"run", "-dt", ALPINE})
Copy link
Member

Choose a reason for hiding this comment

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

please consider podmanTest.PodmanExitCleanly here and throughout the new test where applicable

Copy link
Author

Choose a reason for hiding this comment

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

updated to reflect this

@aaron-ang aaron-ang force-pushed the update-ulimit branch 2 times, most recently from 22d4ec1 to 81fe400 Compare June 17, 2025 18:20
@aaron-ang aaron-ang marked this pull request as ready for review June 17, 2025 18:23
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2025
@aaron-ang
Copy link
Author

What is the merge workflow for this project? Should I always squash my commits into a single commit?

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Does this work correctly with --ulimit host on update? AFAICT it should unset all limts from the spec but the parser sets it to nil which means the update code considers it unset? I think the code likely needs to pass an explicit empty slice in that case?

Comment on lines +381 to +389
# Test persists across container restart
run_podman restart $ctrname

# Verify the ulimits persist after restart
run_podman exec $ctrname sh -c "ulimit -n"
assert "$output" == "2048" "nofile ulimit persists after restart"

run_podman exec $ctrname sh -c "ulimit -u"
assert "$output" == "512" "nproc ulimit persists after restart"
Copy link
Member

Choose a reason for hiding this comment

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

Note you aren't actually verifying that the ulimit is set correctly for the main container process. exec spawns a new process so it has its own limits compared to the main pid.

You likely need to run something like `sh -c "ulimit -n; ulimit -u; sleep 100" as main process and then check with podman logs that the output has the right values.

Comment on lines +392 to +396
run_podman 125 update --ulimit nofile:1024:1024 $ctrname
assert "$output" =~ "error" "Invalid ulimit syntax should fail"

run_podman 125 update --ulimit nofile=2048:1024 $ctrname
assert "$output" =~ "error" "Invalid ulimit values should fail"
Copy link
Member

Choose a reason for hiding this comment

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

That is a match is bad, checking for just "error" can be anything. You should check for the proper error message so you know the actual right error is being returned to users.

@Luap99
Copy link
Member

Luap99 commented Jun 18, 2025

What is the merge workflow for this project? Should I always squash my commits into a single commit?

For a small feature like this yes. In general commits must be logical units and we prefer code, test and docs to be part of the same commit. However if you do some slight refactoring or fix multiple things than they should be in separate commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Change to remote API; merits scrutiny release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE: Add ulimits to podman update
4 participants