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
ansible-test: Set max number of open files in containers to 10240 #75498
Conversation
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.
Instead of requiring users to pass another option to make tests work, I think we should pick a ulimit and have ansible-test set it automatically. The question then becomes, what should the ulimit be?
XFS supports 2 ** 64 files in the system:) I don't think many services check and require higher ulimit than the standard number. We could increase it, say, twice, i.e. to @mattclay if it sounds sensible, i could adjust the number in this PR. |
@Andersson007 Yeah, a hard-coded ulimit of 2048 seems like a reasonable fix for now, since this is the first time I'm aware that this issue has come up. |
to 2048 in test container
deb63ce
to
a05af2e
Compare
Co-authored-by: Matt Clay <matt@mystile.com>
Co-authored-by: Matt Clay <matt@mystile.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
the tests are green now |
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.
Taking a closer look at this, I'm not sure this is what we need.
The default hard limit comes from the Docker daemon, which at least on my system is much higher than 2K. Attempting to raise that limit with --ulimit
fails, so this change would only lower it.
The soft limit of 1K comes from ansible-test
itself. Changing it with --ulimit
will only affect what the container uses, not what ansible-test
uses inside the container.
@Andersson007 Can you run ansible-test shell --docker -vv
without this change and see what ansible-test
reports for RLIMIT_NOFILE
inside the container (the second one reported)?
I see the following:
I also ran
|
$ docker --version Fedora release 33. Docker was installed via |
@Andersson007 OK, that's what I expected. Try changing the limit to 2048 here:
Let me know if that resolves the issue you're seeing. |
@mattclay now the log contains And my tests fail again with the original error:
So it didn't help |
@Andersson007 My main concern with this now is that it will lower the limit for existing users if their limit is higher than 2K. Unfortunately I couldn't find any way to query the docker default without actually running a container. We could just try 2K and see if anyone reports issues, or perhaps pick a higher value to be safe. Since we're still setting the soft limit within ansible-test, a higher hard limit for docker shouldn't cause problems unless it exceeds the system's limit. Thoughts? |
@mattclay it's hard to imagine if anyone really need more than even 2048 files open for purposes of Ansible tests but who knows. The most important question is if the higher limit can cause security issues for testing infrastructure? If not, we could increase it to 4096 or even 10240 and see. |
@Andersson007 Lets go with 10K and see if anyone has issues with it. |
@mattclay done, PTAL |
@mattclay while the collection is still in development and I think it'll take some time, right now this change is not really needed. |
@mattclay it's been done and i've just transferred the new collection to ansible-collections. |
SUMMARY
I'm developing a collection for one service from scratch.
I wrote integration tests.
When trying to run the service with
ansible-test
with--docker
, I got the following error from the service I want to test against:I tried to run
ulimit -n 9000
inside the container with and without--docker-privileged
-> in both the cases i got "error setting limit (Operation not permitted)".With this patch, the following command works now and the service starts successfully:
I'm also OK with if ulimits will be increased in docker files for the tests containers
However, this solution gives more flexibility and covers more possible cases
UPDATE
During discussion we decided to hardcode 10240 as max number of open files to not provide the additional option.
ISSUE TYPE
COMPONENT NAME
ansible-test