fix: descriptor leaking in salt.utils.http.query
What does this PR do?
Wraps the SyncWrapper(AsyncHTTPClient, …) used inside salt.utils.http.query with a context manager so the temporary Tornado IOLoop/socketpair created for each request is always torn down. This stops the salt-minion process from leaking thousands of FDs when repeatedly calling http.query.
What issues does this PR fix or reference?
Previous Behavior
Each call to salt.utils.http.query instantiated a new SyncWrapper, but never invoked close(). Every invocation left an IOLoop thread, epoll FD, and socketpair open, so long-lived minions accumulated thousands of FDs and their RSS climbed steadily.
New Behavior
http.query now uses with SyncWrapper(...) as download_client, ensuring the wrapper’s close() method runs after each request and all resources/FDS are released immediately.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
- [x] Docs
- [x] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
- [x] Tests written/updated
Commits signed with GPG?
Yes
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here's some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at [email protected]. We're glad you've joined our community and look forward to doing awesome things with you!
Is this issue on 3006.x or 3007x too?
Is this issue on 3006.x or 3007x too?
I only caught this bug in 3007.x.
@twangboy Added to changelog.
Can we add this patch to release in 3007.x?
We usually patch bugs on the earliest supported branch where the bug exists. If this bug exists on 3006.x, please patch it there, then the changes will be merged forward into 3007.x and master branches.
This bug was introduced in https://github.com/saltstack/salt/pull/66330.
I don't see the same issue in 3006.x releases.
This bug was introduced in #66330.
I don't see the same issue in 3006.x releases.
Ideally the fix would go into the 3007.x branch then.
Please address the merge conflicts