Skip to content

Conversation

@dabla
Copy link
Contributor

@dabla dabla commented Feb 13, 2025

This pull request fixes a connection leak issue when using the SFTPHook get_conn method which yields a closable sftp connection.

The issue is the connection from the SFTPClient get closed automatically but not the one from the SSHClient, leaving the connection open until the SFTPHook isn't used anymore, this PR make sure the SSHClient also get automatically closed once the SFTP connection isn't needed anymore.

Added an assertion in test_get_close_conn of TestSFTPHook to test this behaviour.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@potiuk potiuk force-pushed the fix/sftp-connection-leak branch from ffc43f1 to 9ede9f2 Compare February 15, 2025 20:51
@potiuk
Copy link
Member

potiuk commented Feb 15, 2025

Rebased. Let's see if my #46608 PR will fis it :)

@potiuk
Copy link
Member

potiuk commented Feb 15, 2025

Seems it does :)

@potiuk potiuk merged commit a9f3cbb into apache:main Feb 15, 2025
61 checks passed
@dabla
Copy link
Contributor Author

dabla commented Feb 17, 2025

Thx @potiuk

dantonbertuol pushed a commit to dantonbertuol/airflow that referenced this pull request Feb 17, 2025
…xt manager from SFTPHook (apache#46716)

* fix: Make sure the SSHClient is also closed when getting a SFTPClient connection

* refactor: Changed call of super get_conn in SFTPHook

* refactor: Only open connection when call on connection has to be done

* refactor: Added types for files and dirs

---------

Co-authored-by: David Blain <david.blain@infrabel.be>
Co-authored-by: David Blain <david.blain@b-holding.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants