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

Add means to Duplicate connections from UI #15574

Merged
merged 30 commits into from
Jun 17, 2021
Merged

Add means to Duplicate connections from UI #15574

merged 30 commits into from
Jun 17, 2021

Conversation

pateash
Copy link
Contributor

@pateash pateash commented Apr 28, 2021

closes: #12401


Description

  • This change allows users to duplicate connections via UI.
  • user can also create duplicates of multiple connections.
  • A descriptive flash message will be shown regarding the success or error in any of the connection duplication.

@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Apr 28, 2021
@pateash
Copy link
Contributor Author

pateash commented Apr 28, 2021

image

  • all the connections will be suffixed with _Copy(NUM) similar to Windows file explorer

image

@pateash
Copy link
Contributor Author

pateash commented Apr 28, 2021

It will show a user-friendly error in case of name conflict ( unique integrity)

image

@pateash pateash marked this pull request as draft April 28, 2021 14:40
@pateash pateash marked this pull request as ready for review April 28, 2021 17:02
@jhtimmins
Copy link
Contributor

@ryanahamilton @ashb Bumping y'all on this since you're code owners here.

I think the code looks solid (nice job on the string update logic @pateash). My only nitpick is if _Copy should be uppercased. If connections typically have snakecase titles, it'd be cleaner to go lowercase (_copy). But if no one else minds then I'm fine with it.

@xinbinhuang
Copy link
Contributor

xinbinhuang commented May 4, 2021

I have the same feeling as @jhtimmins : should it be snakecase _copy instead?

Another thing is: can you also a test case to cover the duplicate logic?
Otherwise, the change looks neat 👍

Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As others have said, we should have it as _copy not _Copy.

Additionally, it should be copy1 not copy(1) so it can be set via env vars if has to. (You can't put () in env var names, so AIRFLOW_CONN_FOO_COPY(1) would not be possible

tests/www/test_views.py Outdated Show resolved Hide resolved
tests/www/test_views.py Outdated Show resolved Hide resolved
tests/www/test_views.py Outdated Show resolved Hide resolved
airflow/www/views.py Outdated Show resolved Hide resolved
airflow/www/views.py Outdated Show resolved Hide resolved
airflow/www/views.py Outdated Show resolved Hide resolved
@pateash pateash marked this pull request as draft May 4, 2021 16:20
@pateash
Copy link
Contributor Author

pateash commented May 5, 2021

As others have said, we should have it as _copy not _Copy.

Additionally, it should be copy1 not copy(1) so it can be set via env vars if has to. (You can't put () in env var names, so AIRFLOW_CONN_FOO_COPY(1) would not be possible

Thanks All for valuable comments,
As per suggestions, I have used _copyN Syntax for duplication,
also test has been added.

@pateash
Copy link
Contributor Author

pateash commented May 11, 2021

@ryanahamilton @ashb
Could you please review and let me know if any more changes required.

@pateash
Copy link
Contributor Author

pateash commented Jun 1, 2021

As others have said, we should have it as _copy not _Copy.

Additionally, it should be copy1 not copy(1) so it can be set via env vars if has to. (You can't put () in env var names, so AIRFLOW_CONN_FOO_COPY(1) would not be possible

done

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@potiuk
Copy link
Member

potiuk commented Jun 2, 2021

Can you please rebase and solve conflicts @pateash ?

@pateash
Copy link
Contributor Author

pateash commented Jun 2, 2021

Can you please rebase and solve conflicts @pateash ?

Thanks @potiuk , done.

@potiuk
Copy link
Member

potiuk commented Jun 7, 2021

@ashb -> any more comments or can we merge it ?

@jhtimmins
Copy link
Contributor

@ashb can you check whether your requested changes have been addressed?

airflow/www/views.py Show resolved Hide resolved
@ashb ashb changed the title #12401 - Duplicating connections from UI Add means to Duplicate connections from UI Jun 10, 2021
Co-authored-by: Ash Berlin-Taylor <[email protected]>
@pateash pateash requested a review from ashb June 12, 2021 13:08
@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Jun 14, 2021
@github-actions
Copy link

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@ashb ashb merged commit 2011da2 into apache:main Jun 17, 2021
@ashb ashb added this to the Airflow 2.2 milestone Jun 17, 2021
@pateash pateash deleted the #12401-creating-duplicate-connection-in-ui branch June 17, 2021 15:25
@jyotsa09
Copy link

jyotsa09 commented Sep 3, 2021

There is a scenario where I feel this is not working as expected.

  • When I have created a connection with name conn_test_copy1 and then I have tried to duplicate this connection. It actually created a connection with name as conn_test_copy2 instead of conn_test_copy1_copy1.
    image

Also in the above scenario if I am trying to duplicate the conn_test_copy1 it's giving me an error of Connection conn_test_copy2 can't be added. Integrity error, probably unique constraint. It's because connection with name conn_test_copy2 is already there but it's looking like we can't duplicate same connection twice.
image

@pateash
Copy link
Contributor Author

pateash commented Sep 4, 2021

@jyotsa09
this is expected behaviour, you should not have any connection with _copyN in the end,
it's just a way to create duplicates, after duplication you are supposed to rename the connection.

@uranusjr
Copy link
Member

uranusjr commented Sep 4, 2021

We should detect this and show a better error message. @jyotsa09 Could you file an issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues okay to merge It's ok to merge this PR as it does not require more tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate connections UI
7 participants