-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Revert commit that changed LimitNOFILE to infinity to avoid regressions #7566
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -32,7 +32,7 @@ RestartSec=5 | |||
| # in the kernel. We recommend using cgroups to do container-local accounting. | ||||
| LimitNPROC=infinity | ||||
| LimitCORE=infinity | ||||
| LimitNOFILE=infinity | ||||
| LimitNOFILE=1048576 | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For the equivalent Equivalent change should hopefully follow soon here 🙏
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for being so slow. I see in the meantime you created a separate PR already (#8924).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries, I know how it is :) Thanks for kickstarting the process with the original attempt here! ❤️ |
||||
| # Comment TasksMax if your systemd version does not supports it. | ||||
| # Only systemd 226 and above support this version. | ||||
| TasksMax=infinity | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on looking into the topic extensively, the following is:
docker.serviceandcontainerd.serviceto function (once they implicitly raise their soft limit to the hard limit as Go 1.19+ does)Additional info
fs.nr_open(leaving it at default1048576, this is the value thatinfinityresolves to).LimitNOFILEcould technically be dropped. It is only relevant to builds before Go 1.19 because AFAIK there is nothing internal explicitly raising the soft limit, so the setting was used to ensure it was sufficient enough forcontainerdto do it's thing (not containers themselves that inherit the limits).containerdtechnically only needs262144(2^18) to support 65k (2^16) busybox containers, which in itself needs over 200GiB of memory. I have shared my investigation + reproduction to back that up.2^16which mitigates the issues and appears to be serving them well. That should still be capable of supporting thousands of containers on systems with memory of 64GB or higher.1024would be ideal and reflect running software on a host outside of a container, and should not cause any regressions with builds using Go 1.19+.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@polarathene thanks for this suggestion, I tried to set the
LimitNOFILE=1024:524288for both thedocker.serviceandcontainerd.serviceusingoverride.conffiles in /etc/systemd/system/docker.service.d and /etc/systemd/system/containerd.service.d and noticed that both the hard limit and soft limit fornofile(within my container) were set to524288. I wonder if the soft limit fromLimitNOFILEis ignored?I know the
override.conffiles are "dropped-in":Output from within the container:
Output on host:
Here is my output of
docker version:If I add the following to my /etc/docker/daemon.json the ulimit hard and soft values for
nofileare correct:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dambrosio @polarathene it's a Golang issue, and will be fixed in the next patch release (the Go maintainers acknowledged a change they made in Go 1.19 was a regression, and a fix will be included in the next patch release); see the discussion on this ticket, and the related backport tickets;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thaJeztah I am well aware and was involved in the discussions to get the issue addressed 😎
@dambrosio my messages are a bit verbose sorry, but I did point this out in my review comment above:
Once that is available, both
dockerd.serviceandcontainerd.serviceshould adjustLimitNOFILEas suggested, and the soft limit will be respected for containers (without being an issue for either daemons needs as since Go 1.19).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOH! I got lost in all the linked issues, and replied from my phone, yes ... I knew you knew...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggestion seems completely reasonable assuming the syntax works even on older versions of systemd. I think centos7 is v219?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If previous values of
1048576andinfinityhave worked fine prior to systemd v240, then yesLimitNOFILEshould be fine applying the soft/hard limit suggested here.As long as the releases are built with Go 1.19+ (otherwise the daemons would restrained to running approx 150 containers).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go updated with fix
RLIMIT_NOFILEsyscall fix: runtime: automatically bump RLIMIT_NOFILE on Unix [1.19 backport] golang/go#59063contrainerd.serviceanddocker.servicecan now update their configs to move away fromLimitNOFILE=infinity🎉Could the
LimitNOFILE=1024:524288change request be applied, and queue this PR for review / merge? 😀EDIT: I've created the equivalent PR for
moby(docker.serviceand friends): moby/moby#45534Let me know if you'd like a similar PR for
containerd(avoids the noise present here, and the original author has not applied the suggested feedback).Confirmation
Test values:
containerd.service:LimitNOFILE=2048:8192docker.service:LimitNOFILE=3072:4096This was tested on a Vultr VPS instance with Ubuntu 23.04 and installing Docker via the docs:
docker-ce 23.0.6containerd containerd.io 1.6.21 3dce8eb055cbb6872793272b4f20ed16117344f8runc version: v1.1.7-0-g860f061docker info