salt icon indicating copy to clipboard operation
salt copied to clipboard

fix: descriptor leaking in salt.utils.http.query

Open vitalvas opened this issue 2 months ago • 7 comments

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

vitalvas avatar Nov 12 '25 17:11 vitalvas

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!

welcome[bot] avatar Nov 12 '25 17:11 welcome[bot]

Is this issue on 3006.x or 3007x too?

dwoz avatar Nov 14 '25 09:11 dwoz

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?

vitalvas avatar Nov 14 '25 15:11 vitalvas

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.

twangboy avatar Nov 14 '25 21:11 twangboy

This bug was introduced in https://github.com/saltstack/salt/pull/66330.

I don't see the same issue in 3006.x releases.

vitalvas avatar Nov 17 '25 14:11 vitalvas

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.

dwoz avatar Nov 18 '25 09:11 dwoz

Please address the merge conflicts

twangboy avatar Nov 24 '25 19:11 twangboy