apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
36.86k stars 14.25k forks source link

"Test" airflow connection does not work #39968

Open swasenius opened 4 months ago

swasenius commented 4 months ago

Apache Airflow version

2.9.1

If "Other Airflow 2 version" selected, which one?

No response

What happened?

After migration 2.5.3 -> 2.9.1 we noticed that the connectivity "Test" in Airflow UI does not work for JDBC connections. We do have AIRFLOWCORETEST_CONNECTION enabled. It will give an error on the the UI such as: "The conn_id <random string> isn't defined". The string here is always changing so it somehow does not pick up the connection_id right.

What you think should happen instead?

Testing JDBC connectivity should work, if connection details are correct.

How to reproduce

When testing JDBC connection in Airflow UI.

Operating System

Debian 12

Versions of Apache Airflow Providers

airflow@airflow-worker-0:/opt/airflow$ pip freeze |grep airflow-prov apache-airflow-providers-amazon==7.4.1 apache-airflow-providers-celery==3.6.2 apache-airflow-providers-cncf-kubernetes==8.0.0 apache-airflow-providers-common-io==1.3.1 apache-airflow-providers-common-sql==1.12.0 apache-airflow-providers-docker==3.10.0 apache-airflow-providers-elasticsearch==5.3.4 apache-airflow-providers-fab==1.0.4 apache-airflow-providers-ftp==3.8.0 apache-airflow-providers-google==10.17.0 apache-airflow-providers-grpc==3.4.1 apache-airflow-providers-hashicorp==3.6.4 apache-airflow-providers-http==4.10.1 apache-airflow-providers-imap==3.5.0 apache-airflow-providers-jdbc==4.2.2 apache-airflow-providers-microsoft-azure==10.0.0 apache-airflow-providers-microsoft-mssql==3.6.1 apache-airflow-providers-mysql==5.5.4 apache-airflow-providers-odbc==4.5.0 apache-airflow-providers-openlineage==1.7.0 apache-airflow-providers-postgres==5.10.2 apache-airflow-providers-redis==3.6.1 apache-airflow-providers-sendgrid==3.4.0 apache-airflow-providers-sftp==4.9.1 apache-airflow-providers-slack==8.6.2 apache-airflow-providers-smtp==1.6.1 apache-airflow-providers-snowflake==5.4.0 apache-airflow-providers-sqlite==3.7.1 apache-airflow-providers-ssh==3.10.1

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

Code of Conduct

boring-cyborg[bot] commented 4 months ago

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

RNHTTR commented 4 months ago

It's worth noting that this was disabled due to a security vulnerability.

aritra24 commented 4 months ago

Had a quick look, My guess would be the connection url being put in might be malformed in some way, something like "jdbc:postgresql://host:port/database?properties" while what it want's is just the host:port form? because the logs have this error message Invalid connection string: jdbc://jdbc:postgresql://admin@localhost%3A5432%2Fairflow/?__extra__=%7B%7D. I believe the error message in the UI could probably be clearer? @swasenius could you check and let us know?

swasenius commented 4 months ago

Here's an example: jdbc:sqlserver://XXX.XXX.XX.XX:1433 and this looks like MS SQL server. User ie login is define in it's own field.

aritra24 commented 4 months ago

Yes @swasenius , the field expects just the XXX.XXX.XX.XX:1433 part and appends the jdbc:// part on it's own. I assume for MSSQL we are expected to use the Microsoft SQL Server connection type.

swasenius commented 4 months ago

If I remove the first part and use XXX.XXX.XX.XX:1433, I get: Class com.microsoft.sqlserver.jdbc.SQLServerDriver is not found

but when I try it with the one using MSSQL connection type, it works. <- This (MSSQL) is not however a jdbc connection..

pateash commented 4 months ago

I can check this out, If no one else is picking this up. Please assign this to me.

pateash commented 3 months ago

Couple of things I found,

  1. We can't provide jdbc: as it is automatically provided. => we need to add better documentation in UI and may be add a better error message.
image