Skip to content
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

SFTPHook requires param 'ftp_conn_id' to be passed even for ssh connections #20144

Closed
2 tasks done
saveriogzz opened this issue Dec 8, 2021 · 11 comments
Closed
2 tasks done
Assignees
Labels
area:providers kind:bug This is a clearly a bug

Comments

@saveriogzz
Copy link
Contributor

Apache Airflow Provider(s)

sftp

Versions of Apache Airflow Providers

apache-airflow-providers-sftp==2.2.0

Apache Airflow version

2.2.2 (latest released)

Operating System

Ubuntu 20.04.3 LTS

Deployment

Docker-Compose

Deployment details

No response

What happened

When instantiating an SFTPHook in order to create a connection to an sftp server, I noticed that if I was passing the parameter ssh_conn_id, the hook was trying to connect to localhost, whereas if I am passing ftp_conn_id, I obtain the desired connection.

def __init__(self, ftp_conn_id: str = 'sftp_default', *args, **kwargs) -> None:
kwargs['ssh_conn_id'] = ftp_conn_id
super().__init__(*args, **kwargs)

What you expected to happen

I would expect to be able to instantiate an sftp conection using the parameter ssh_conn_id instead of ftp_conn_id.

How to reproduce

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@saveriogzz saveriogzz added area:providers kind:bug This is a clearly a bug labels Dec 8, 2021
@potiuk
Copy link
Member

potiuk commented Dec 8, 2021

I would expect to be able to instantiate an sftp conection using the parameter ssh_conn_id instead of ftp_conn_id.

Why?

@saveriogzz
Copy link
Contributor Author

To be consistent with the SFTPOperator and not to mislead the type of connection to be used since there are both FTP and SFTP connections!

@potiuk
Copy link
Member

potiuk commented Dec 8, 2021

OK. Works for me. Sftp is really ssh under-the-hood indeed. But you should make sure to keep deprecated previous option working too. Assigning you :D

@kaxil
Copy link
Member

kaxil commented Dec 8, 2021

I would say rather than deprecating, allow both as it is quite common to use SSH for get and send files

@potiuk
Copy link
Member

potiuk commented Dec 9, 2021

It's really about the "iniit" parameter name of Hook, so I am not sure if we should have two variants :). One should be blesssed.

@potiuk
Copy link
Member

potiuk commented Dec 9, 2021

And there is disconnect which one is used between the Operator and Hook.

@kaxil
Copy link
Member

kaxil commented Dec 9, 2021

Oh yes this is regarding the Hook, I am fine with that.

The SftpOperator uses the SSHHook anyway so all food 😅 - good

@potiuk
Copy link
Member

potiuk commented Dec 9, 2021

Food is good 🥫

@potiuk
Copy link
Member

potiuk commented Dec 9, 2021

:D

@kaxil
Copy link
Member

kaxil commented Dec 9, 2021

d

@eladkal
Copy link
Contributor

eladkal commented Dec 14, 2021

fixed by #20164

@eladkal eladkal closed this as completed Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers kind:bug This is a clearly a bug
Projects
None yet
Development

No branches or pull requests

4 participants