[AIRFLOW-3268] Cannot pass SSL dictionary to mysql connection via URL#4113
Conversation
0e344d2 to
d9e399f
Compare
Codecov Report
@@ Coverage Diff @@
## master #4113 +/- ##
==========================================
+ Coverage 76.69% 76.71% +0.01%
==========================================
Files 199 199
Lines 16233 16238 +5
==========================================
+ Hits 12450 12457 +7
+ Misses 3783 3781 -2
Continue to review full report at Codecov.
|
|
Can this be documented somewhere i.e. what can be passed into Extras field? Currently, a user needs to check the source code to see what can be passed which isn't ideal. |
f32b23e to
6d0eff9
Compare
|
Hey @kaxil - Why not :). I added it now, reverse engineering it from the code. It's good to leave the world a bit better than you found. I added useful documentation now to MySQL connection. I will soon submit CloudSQL query one which I will add similar info about new cloudsql:// connection and about underlying Postgres connection as well. |
|
@potiuk Thanks, appreciate that :) . Can you update the commit message as well to something along the line of "Fix Issue with Extras field in MySQL connection" or something that help users identify what issue was solved. The current commit message is more of a "Jira issue". |
It is impossible to pass 'ssl' dictionary to MySql hook as an extrai param via URL connection. While there is a code to pass the 'ssl' extra query parameter, MySqldb requires this parameter to be dictionary. When you want to create a connection via URL, you can at most have ?ssl= url-encoded string rather than dictionary and this is how it is passed (as string). What happens then in MySqldb, is that all SSL parameters are ignored and MySQL establishes a non-SSL connection silently. This is fixed by detecting if 'ssl' is a string and converting it to json dictionary in such case. Also documentation is updated to show examples of MySQL extras field and how URI for MySQL connection shoudl be constructed.
6d0eff9 to
d856af3
Compare
|
Sure :). Done. |
|
Awesome. Thanks @potiuk |
Make sure you have checked all steps below.
Jira
Description
It is impossible to pass 'ssl' dictionary to MySql hook as an extrai
param via URL connection. While there is a code to pass the 'ssl'
extra query parameter, MySqldb requires this parameter to be
dictionary. When you want to create a connection via URL,
you can at most have ?ssl= url-encoded string rather than
dictionary and this is how it is passed (as string). What happens
then in MySqldb, is that all SSL parameters are ignored
and MySQL establishes a non-SSL connection silently.
This is fixed by detecting if 'ssl' is a string and converting
it to json dictionary in such case.
Tests
TestMySqlHookConn:
test_get_conn_ssl_as_dictionary
test_get_conn_ssl_as_string
Commits
Documentation
No new functionality
Code Quality
flake8