-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Make conn_id unique in Connections table #9067
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
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
|
airflow/migrations/versions/8d48763f6d53_add_unique_constraint_to_conn_id.py
Outdated
Show resolved
Hide resolved
potiuk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a note in UPDATING.md about this change. Also (but probably later) some migration tool for airflow 2.0 should also deal with this case if someone already has connection in their database . We will have to figure out migration scheme, but I think a note in UPDATING.md will be enough to remember about doing it.
|
I have removed the test method |
|
I wonder if we should mark this field as non nullable. conn_type should also not be empty, but that's another issue. |
|
Would it be a big problem to use this field as the primary key instead of just adding a second unique index? The primary key is also a unique index. |
ashb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the airflow.secrets.local_filesystem needs updating too -- it still supports multiple connections with the same id.
Oh, this is my first time reading about this backend. Should we stop and raise an exception in case of multiple connections or just load the last one specified ? |
|
@Hasan-J I think It would be a better idea to raise an exception. |
As written in apache#9067, Airflow 2.0 introduces a change that requires that all Airflow connections be unique (whereas Airflow 1.10.x technically supports two connections with the same name and potentially the same values). With this commit, we show "warning" in the Airflow UI for users with duplicate connections
As written in apache#9067, Airflow 2.0 introduces a change that requires that all Airflow connections be unique (whereas Airflow 1.10.x technically supports two connections with the same name and potentially the same values). With this commit, we show "warning" in the Airflow UI for users with duplicate connections
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
apache/airflow#9067 made conn_id unique, and this is effective from 2.0.*. Due to this change, BaseHook.get_connections() will return a List of length 1, or raise Exception. In such a case, we should simply always get the only element from the result from BaseHook.get_connections(), and drop random.choice() in BaseHook.get_connection(), which was only applicable for the earlier setting (multiple connections is allowed for single conn_id) GitOrigin-RevId: 74ed92b3ff34fa3b6af27c17f44ad4573b517bbd
Closes #8608
Added an alembic revision, if the user already has multiple records with the same
conn_idin the connections table, it throws an exception during
airflow db upgradewith a clearmessage.
Make sure to mark the boxes below before creating PR: [x]
In case of fundamental code change, 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 UPDATING.md.
Read the Pull Request Guidelines for more information.