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

Make buildah match podman for handling of ulimits #5275

Merged
merged 1 commit into from Feb 5, 2024

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Jan 17, 2024

Podman currently sets the ulimits of nofile and nproc to max in rootless mode, if the user does not override.

Buildah on the other hand just passes in the current defaults.

Podman build should match podman run, and this will fix that problem.

Fixes: #5273

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?

Buildah now sets the maximum ulimits nofile and nproc by default.

@@ -54,6 +54,9 @@ const (
SNP TeeType = "snp"
)

// DefaultRlimitValue is the value set by default for nofile and nproc
const RLimitDefaultValue = uint64(1048576)
Copy link
Member

Choose a reason for hiding this comment

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

Where do these values come from? Are they always the default everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the default from Podman, no idea where it came from.

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 added it

Copy link
Member Author

Choose a reason for hiding this comment

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

Might have been a value from Docker?
https://bbs.archlinux.org/viewtopic.php?id=285058

Copy link
Member Author

Choose a reason for hiding this comment

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

As of 7 years ago was a kernel max.
https://serverfault.com/questions/819119/xtrabackup-too-many-open-files-more-than-1048576

Might want to use something even higher.

cat /proc/sys/kernel/pid_max
4194304

Copy link
Member Author

Choose a reason for hiding this comment

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

Under Moby I see.
./libnetwork/docs/vagrant-systemd/docker.service:LimitNOFILE=1048576
./libnetwork/docs/vagrant-systemd/docker.service:LimitNPROC=1048576

Copy link
Member

Choose a reason for hiding this comment

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

Digging into the git history, these defaults were introduced in Podman with:

to address:

Copy link
Member Author

Choose a reason for hiding this comment

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

The question is do we continue to roll with it, or should we increase it?

Copy link
Member

Choose a reason for hiding this comment

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

I'd vote to keep Podman and Buildah in lockstep. I don't know if there's a place to tuck the default values so both could reference them from the same place, that would be nice. I think 1048576 for the kernel max is good for now.

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 move this constant to c/common? No need to block this PR on it but we should use every occasion to avoid future code divergence; this PR smells like a good example :)

@rhatdan rhatdan force-pushed the ulimit branch 2 times, most recently from bd9c5f0 to 7569418 Compare January 19, 2024 11:19
@nalind
Copy link
Member

nalind commented Jan 19, 2024

I must be missing something. In the test, the build is printing the soft limits it's seeing (here), but the test is expecting those values to match the hard limits (gathered here and here) it has.
The code, however, is passing along the current-set limits, both hard and soft.
Why does the test pass?

@rhatdan
Copy link
Member Author

rhatdan commented Jan 22, 2024

@nalind we are only printing the hard limit and testing off of it.

@nalind
Copy link
Member

nalind commented Jan 22, 2024

@nalind we are only printing the hard limit and testing off of it.

I think you're mistaken about which field the RUN commands in tests/bud/bud.limits/Containerfile are printing.

Podman currently sets the ulimits of nofile and nproc
to max in rootless mode, if the user does not override.

Buildah on the other hand just passes in the current defaults.

Podman build should match podman run, and this will fix that problem.

Fixes: containers#5273

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

rhatdan commented Feb 2, 2024

@nalind this is ready to go in, I believe.

@rhatdan rhatdan added the 5.0 label Feb 3, 2024
@rhatdan
Copy link
Member Author

rhatdan commented Feb 3, 2024

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

/lgtm

@@ -54,6 +54,9 @@ const (
SNP TeeType = "snp"
)

// DefaultRlimitValue is the value set by default for nofile and nproc
const RLimitDefaultValue = uint64(1048576)
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 move this constant to c/common? No need to block this PR on it but we should use every occasion to avoid future code divergence; this PR smells like a good example :)

Copy link
Contributor

openshift-ci bot commented Feb 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [giuseppe,rhatdan,vrothberg]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 20ae380 into containers:main Feb 5, 2024
34 checks passed
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 6, 2024
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.

Low ulimits when building with docker-compose/podman-compose
5 participants