Repository navigation
Remove LimitNOFILE from containerd.service - #8924
Conversation
|
Hi @polarathene. Thanks for your PR. I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Instead of just removing the line, should their be a comment for cases it might still be need or used? |
For the equivalent PR at moby, it was requested to drop the line completely without leaving any additional context. I brought up some points where it could be beneficial to keep some context around. If maintainers of containerd have a different opinion, let me know and I'll adjust the commit 👍 Additional Information for
|
|
Since such files are likely to be modified by distros (and only apply to those using systemd at all), I wonder whether we should carry this file at all. IMHO it really belongs into the distro domain |
The majority of linux distros use systemd, the project should ship a standardized config to avoid problems like the current one this PR is resolving from being repeated across each individual package maintainer. I've seen that stance and problems with other software like the I'm not aware of any distros that are modifying this config, do you have any in mind? You will find various third-party advice online to modify the config directly or apply an override to workaround this exact problem, but often the solution is incorrect and not understood well, it just minimized the issue for them. |
DistroWatch currently lists 322 non-systemd distros. Including those specifically made as container host (eg. Rancher).
There's lots of other hackish or broken stuff in there (even guessing host arch wrong, etc), but besides, Certainly, it would be better if we had a way to generate these files from some more high level data source, where
Practically all have to, at least for the broken ExecStart line: And the explicit modprobe'ing is |
I don't think so. In cases where it is needed it can be trivially patched in, either by patching the actual file when building a package or via systemd drop-in at runtime. @metux Its still useful to users not running from distro packages. |
186 with systemd vs 66 non-systemd active linux distros (queried via DistroWatch advanced search):
Regardless of how you came across your 322 metric, I'd assume the number with systemd is larger (if we don't limit to Linux and Active filters, the result is 596 distros), and having over 50% does count as the majority. Although when I made that statement, it was with more pragmatic intentions of well-known distros, especially those you'd generally encounter as a Docker host.
It's fine as a reference. Usually changes can be applied by the packager with a variety of options, including natively with systemd drop-ins.
Sorry, by modifying the config I was specifically referring to the context of the PR In VMware It's far better to have a central reference, especially when changes occur that require that init script to be modified. Each downstream distro packager needs to become aware of the change and resolve it (potentially from the user report providing a solution that may have already been handled by another packager prior), many times you'll get a report though and none of downstream has time to investigate and resolve it. In this case I investigated the problem for Thankfully, I was able to get in touch with systemd devs and identify an improvement there that resolved the issue. Downside being that VM guests would need to run that version of systemd or newer to benefit vs updating the In the context of this PR, |
|
Note to maintainers: For this to be fully correct, the Go runtime should be 1.19+ as that is the version that introduced Go raising it's own soft-limit. We should note this in the changelog, or even add dummy file to keep containerd compiling with older Go versions (if it does still compile with 1.18 on the release branches) to prevent subtle misbehavior caused by no longer explicitly raising the soft-limit. |
Since go.mod explicitly demands 1.20, I doubt that we ever need to care about pre-1.19 anymore :p |
|
That was merely a suggestion with older toolchain versions; it's definitely possible that e.g. a hyperscaler might try to compile with an older Go in order to support the long-term support branch of their container OS. |
if the line is actively harmful.. maybe make a statement explaining the harm of uncommenting it.. |
Covered in the commit message (same content as the PR description), notably the last line about excessive soft limit. Originally in the equivalent PR for moby I had opted to keep the line with the expected implicit default used explicitly. It included a comment for context:
It communicates the intent rather than the harm from excessive values, which for maintainers would have at least had EDIT: I already touched on this earlier in this PR discussion 😅 For maintainers at least, I've ensured a solid "paper trail" for traceability, with plenty of information to justify why it should be changed away from |
|
Note that this PR needs the commit repushed with the canonical form of <90 char or less subject> followed by blank line, followed by any length descriptive message, followed by blank line and then the "Signed-off-by: "; without this the full CI checks are not running due to: |
|
Looks good to me, can you update the commit according to "- FAIL - commit subject exceeds 90 characters". Looks like an empty line would do the trick after the subject line. |
364bf95 to
cdafec5
Compare
Remove `LimitNOFILE` from `containerd.service` to rely on the systemd v240 implicit default of `1024:524288`. On supported platforms with systemd prior to v240, packagers will patch the service with an explicit `LimitNOFILE=1024:524288`. - `1024` soft limit is an implicit default, avoiding unexpected breakage. Software that needs a higher limit should request to raise the soft limit for its process. - `524288` hard limit is an implicit default since systemd v240 and is adequate for most processes (_half of the historical limit from `fs.nr_open` of `1048576`_), while 4096 is the implicit default from the kernel (often too low). - The hard limit may not exceed `fs.nr_open` (_which a value of `infinity` will resolve to_). On most systems with systemd v240 or newer, this will resolve to an excessive size of 2^30 (over 1 billion). - When set to `infinity` (usually as the soft limit) software may experience significantly increased resource usage, resulting in a performance regression or runtime failures that are difficult to troubleshoot. Signed-off-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
cdafec5 to
3ca39ef
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
Hi, just a friendly ping to confirm everything is all sorted for this PR?
|
@neersighted any preferences on that? I recall we used to have some commented-out options with a comment explaining why (and having a commented-out line was convenient during packaging, as we could just use otherwise LGTM |
Major release v1 -> v2. Dropped patch as it is no longer necessary: containerd/containerd#8924 containerd-shim and containerd-shim-runc-v1 were removed. https://github.com/containerd/containerd/releases/tag/v2.0.2 Signed-off-by: Christian Stewart <christian@aperture.us>
Major release v1 -> v2. Dropped patch as it is no longer necessary: containerd/containerd#8924 containerd-shim and containerd-shim-runc-v1 were removed. https://github.com/containerd/containerd/releases/tag/v2.0.2 Signed-off-by: Christian Stewart <christian@aperture.us> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Major release v1 -> v2. Dropped patch as it is no longer necessary: containerd/containerd#8924 containerd-shim and containerd-shim-runc-v1 were removed. https://github.com/containerd/containerd/releases/tag/v2.0.2 Signed-off-by: Christian Stewart <christian@aperture.us>
Major release v1 -> v2. Dropped patch as it is no longer necessary: containerd/containerd#8924 containerd-shim and containerd-shim-runc-v1 were removed. https://github.com/containerd/containerd/releases/tag/v2.0.2 Signed-off-by: Christian Stewart <christian@aperture.us>
Major release v1 -> v2. Dropped patch as it is no longer necessary: containerd/containerd#8924 containerd-shim and containerd-shim-runc-v1 were removed. https://github.com/containerd/containerd/releases/tag/v2.0.2 Signed-off-by: Christian Stewart <christian@aperture.us>
Custom daemonset to re-add the nofile-infinity config removed in containerd 2.0 by containerd/containerd#8924
This change aligns with containerd PR #8924 which removed this problematic configuration in containerd 2.0. The LimitNOFILE=infinity setting can cause performance issues and resource exhaustion. Systemd v240+ provides implicit defaults of 1024:524288 which are adequate for most use cases. Reference: containerd/containerd#8924
…n Kubernetes 1.34+ What: Restricts the number of connections/ports/file descriptors that HAProxy and Reticulum can/will requisition. Why: It seems the containerd runtime introduced in Kubernetes 1.34+ (at least on DigitalOcean) changes the file descriptor limit to be unlimited. This seems to cause HAProxy to attempt to allocate too much memory on startup and Kubernetes to kill it; and it also causes Reticulum to use around 1.7Gi instead of around 180Mi. Constraining the number of connections/ports/file descriptors for HAProxy/Reticulum prevents the pods from being killed and returns the memory usage to normal. Notes: It would be a little cleaner/nicer to constrain HAProxy via an ENV variable, argument, or config value, but setting the file descriptor limit directly for the whole container via ulimit -n was the only way that was found to remedy the issue with the current version of HAProxy (future versions may be able to use `fd-hard-limit`). The limit of 1048576 (2^20) was chosen because it appears to be a common setting for modern Linux systems and seems to keep the memory usage similar to what it was in Kubernetes 1.33 and below. HAProxy seems to be the one that causes the pod evictions/crashes when starting up, while Reticulum just seems to use a bunch more memory, i.e. fixing Reticulum without fixing HAProxy, won't allow everything to start, but fixing HAProxy without fixing Reticulum will. The `"$@"` and `--` in the command field for HAProxy is to allow the arguments for HAProxy to be embedded into the `sh -c` string; this allows them to continue to be specified/commented in the args field as normal. References: * https://elixirforum.com/t/elixir-erlang-docker-containers-ram-usage-on-different-oss-kernels/57251 * containerd/containerd#7566 * containerd/containerd#8924 * haproxy/haproxy#2043 * https://stackoverflow.com/questions/78304096/haproxy-2-5-0-is-killed-right-after-doing-a-docker-compose-up-d
…bs to be run What: Restricts the number of connections/ports/file descriptors that HAProxy and Reticulum can/will requisition. Why: It seems the containerd runtime introduced in Kubernetes 1.34+ (at least on DigitalOcean) changes the file descriptor limit to be unlimited. This seems to cause HAProxy to attempt to allocate too much memory on startup and Kubernetes to kill it; and it also causes Reticulum to use around 1.7Gi instead of around 180Mi. Constraining the number of connections/ports/file descriptors for HAProxy/Reticulum prevents the pods from being killed and returns the memory usage to normal. Notes: It would be a little cleaner/nicer to constrain HAProxy via an ENV variable, argument, or config value, but setting the file descriptor limit directly for the whole container via ulimit -n was the only way that was found to remedy the issue with the current version of HAProxy (future versions may be able to use `fd-hard-limit`). The limit of 1048576 (2^20) was chosen because it appears to be a common setting for modern Linux systems and seems to keep the memory usage similar to what it was in Kubernetes 1.33 and below. HAProxy seems to be the one that causes the pod evictions/crashes when starting up, while Reticulum just seems to use a bunch more memory, i.e. fixing Reticulum without fixing HAProxy, won't allow everything to start, but fixing HAProxy without fixing Reticulum will. The `"$@"` and `--` in the command field for HAProxy is to allow the arguments for HAProxy to be embedded into the `sh -c` string; this allows them to continue to be specified/commented in the args field as normal. References: * https://elixirforum.com/t/elixir-erlang-docker-containers-ram-usage-on-different-oss-kernels/57251 * containerd/containerd#7566 * containerd/containerd#8924 * haproxy/haproxy#2043 * https://stackoverflow.com/questions/78304096/haproxy-2-5-0-is-killed-right-after-doing-a-docker-compose-up-d
This is the equivalent of moby/moby#45534 (see for additional insights and review discussion), and replaces an earlier PR attempt: #7566 (original author is not responding to feedback)
Closes: #7566
Remove
LimitNOFILEfromcontainerd.serviceto rely on the systemd v240 implicit default of1024:524288. On supported platforms with systemd prior to v240, packagers are expected to patch the service with an explicitLimitNOFILE=1024:524288.1024soft limit is an implicit default, avoiding unexpected breakage. Software that needs a higher limit should request to raise the soft limit for its process.524288hard limit is an implicit default since systemd v240 and is adequate for most processes (half of the historical limit fromfs.nr_openof1048576), while 4096 is the implicit default from the kernel (often too low).fs.nr_open(which a value ofinfinitywill resolve to). On most systems with systemd v240 or newer, this will resolve to an excessive size of 2^30 (over 1 billion).infinity(usually as the soft limit) software may experience significantly increased resource usage, resulting in a performance regression or runtime failures that are difficult to troubleshoot.