Skip to content

Conversation

@abhilash1in
Copy link
Contributor

Summary:

Add a description (string) field to store additional details about a connection.

UI:

Screen Shot 2020-09-10 at 4 58 10 PM
Screen Shot 2020-09-10 at 4 59 02 PM

CLI:

(airflow) abhilash1in@Abhilashs-MBP airflow % airflow connections add --conn-description "test description" --conn-type mysql --conn-host host --conn-login user --conn-password password test_conn

        Successfully added `conn_id`=test_conn : mysql://user:******@host:

(airflow) abhilash1in@Abhilashs-MBP airflow % airflow connections get test_conn
[2020-09-10 17:02:42,279] {base_hook.py:67} INFO - Using connection to: id: test_conn. Host: host, Port: None, Schema: None, Login: user, Password: XXXXXXXX, extra: None
Id: 48
Conn Id: test_conn
Conn Type: mysql
Description: test description
Host: host
Schema: null
Login: user
Password: password
Port: null
Is Encrypted: true
Is Extra Encrypted: true
Extra: {}
URI: mysql://user:password@host

related: #10840

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
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.

@boring-cyborg boring-cyborg bot added area:CLI area:webserver Webserver related Issues labels Sep 11, 2020
@abhilash1in abhilash1in marked this pull request as ready for review September 11, 2020 05:39
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rule R0913 of pylint expected functions and methods to have utmost 10 arguments. The __init__ method of Connection class already had 10 arguments. I added description which made it 11. So, had to disable rule R0913 and I followed the convention here.

Would it be better to replace # pylint: disable=R0913 with #pylint: disable=too-many-arguments and add it at the end of the line class Connection(Base, LoggingMixin): instead of disabling the rule for the whole file?

Copy link
Member

@turbaszek turbaszek Sep 13, 2020

Choose a reason for hiding this comment

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

Would it be better to replace # pylint: disable=R0913 with #pylint: disable=too-many-arguments and add it at the end of the line class Connection(Base, LoggingMixin):

That would be preferable as others will know what exactly is disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :) Added #pylint: disable=too-many-arguments to __init__ method of Connection class.

@turbaszek
Copy link
Member

For me this looks good just one comment 👌

@turbaszek turbaszek requested a review from kaxil September 14, 2020 06:52
@abhilash1in
Copy link
Contributor Author

@kaxil waiting for your review 🙂

@abhilash1in
Copy link
Contributor Author

abhilash1in commented Sep 18, 2020

Can this be added to Airflow 1.10.13 milestone?

@potiuk
Copy link
Member

potiuk commented Sep 18, 2020

@abhilash1in -> this one looks like more of a convenience than an important change and we actually only cherry-pick to 1.10* what is absolutely necessary. We are getting closer to 2.0 release and we also need to have some "nice features" in 2.0 to get people more excited to migrate to it ;). Also we have two versions of the UI in 1.10 and if we add it to the DB we would have to also add it to both UIs. Plus we also have connection retrieval from the secret backends, so I guess @kaxil's review will point it out that we will have to add similar capabilities to secret backends.

I think it's far too little gain and far too much complexity to try to cherry-pick that one.

@abhilash1in
Copy link
Contributor Author

@potiuk that makes sense, thank you. I'm okay with this being added to 2.0.

Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

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

Tests are failing

@abhilash1in
Copy link
Contributor Author

Tests are failing

@kaxil There were two alembic heads since a new migration was pushed to master after I created my migration (both had the same down_revision). Tests were failing because of the multiple heads.

I've added a new commit to merge the alembic heads and rebased my fork to be in sync with master.

Copy link
Member

Choose a reason for hiding this comment

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

Let's update the other migration in place since this PR is not merged instead of merging the heads

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Waiting for the tests to finish running.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaxil some checks were skipped although nothing else failed, not sure why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaxil can you please review? Would be great if we can close this soon.

@turbaszek turbaszek requested a review from kaxil September 19, 2020 09:36
@mik-laj
Copy link
Member

mik-laj commented Sep 20, 2020

Plus we also have connection retrieval from the secret backends, so I guess @kaxil's review will point it out that we will have to add similar capabilities to secret backends.

Descriptions are only useful in the Web UI, and connections from the secret backends are not visible in Airflow, so it is not necessary to add support for this field in the backend secret.

@potiuk
Copy link
Member

potiuk commented Sep 20, 2020

Descriptions are only useful in the Web UI, and connections from the secret backends are not visible in Airflow, so it is not necessary to add support for this field in the backend secret.

Recently there was a discussion about showing the "names" but not "values" of the connections - so that we can see the connections in the UI even if they are coming from the secret backend. I think for 2.0 we should consciously decide what we do with the connection coming from the secrets and potentially show them in the UI. Otherwise it might be very misleading - the user sees a different "reality" than is "viewed" by the workers.

I believe if we want to add a new "property" of connection - it is very much related to what we are going to do with displaying them in UI (including secret backends)

WDYT @mik-laj - is it good that we do not see secret backend connection, and when we have the connection in db, we see a wrong one ? I think it's rather bad and might be super-confusing for the user.

That's why I think we should first decide what we want to do with the connections and later think about adding new properties to them.

@mik-laj
Copy link
Member

mik-laj commented Sep 20, 2020

@potiuk I'm eager to talk about the mailing list, but in my opinion displaying the item list is a significant extension of the backend secret concept. During its development, the topic of the web UI was discussed and it was decided that the backend secret is just a single interface with the get(key) method. We have also decided that we do not need to display these elements in the Web UI, as users can learn about these keys from their administrator.

WDYT @mik-laj - is it good that we do not see secret backend connection, and when we have the connection in db, we see a wrong one ? I think it's rather bad and might be super-confusing for the user.

This is confusing, and I agree that it is worth warning users about the consequences of configuring the backend secret. I think the warning "Your administrator has set up a secret backend. The data displayed in the Web UI may not represent the state available for the workers". I am afraid that reading any of the values by the webserver can be problematic in corporate environments as corporate environments have a very strict secret access policy. The most common environments I take care of are deployed consisting of several GCP projects. The webserver is in a project that cannot activate the API or access it at all.

Recently, I even had to deal with a issues related to it. In one case, the webserver still tried to make connections to the backend secret, but it never succeeded.
#10365

@prakshalj0512
Copy link
Contributor

@abhilash1in It'd be great if you could add this same field for Variables.

@abhilash1in
Copy link
Contributor Author

abhilash1in commented Oct 4, 2020

@turbaszek @kaxil @potiuk @mik-laj Can someone please review and close this PR?

@mik-laj
Copy link
Member

mik-laj commented Oct 4, 2020

@kaxil do you think this PR requires changes to the secret backend? as I think the backends are working now, the additional columns have no effect and there is no obstacle to merging this change.

@kaxil
Copy link
Member

kaxil commented Oct 11, 2020

@kaxil do you think this PR requires changes to the secret backend? as I think the backends are working now, the additional columns have no effect and there is no obstacle to merging this change.

Yup, it will continue to work

@kaxil
Copy link
Member

kaxil commented Oct 11, 2020

Rebased the PR to the latest master, will merge as soon as CI is green

@mik-laj
Copy link
Member

mik-laj commented Oct 12, 2020

One tests failed:

FAILED tests/utils/test_db.py::TestDb::test_only_single_head_revision_in_migrations

@abhilash1in
Copy link
Contributor Author

Rebased to the latest master.

@mik-laj
Copy link
Member

mik-laj commented Oct 13, 2020

I also rebased to latest master.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Revises: bef4f3d11e8b
Revises: 98271e7606e2

@kurtqq
Copy link
Contributor

kurtqq commented Nov 17, 2020

This will be very helpful!
@abhilash1in any chance you can finalize?

@mik-laj
Copy link
Member

mik-laj commented Nov 17, 2020

@abhilash1in Can you do a rebase?

@abhilash1in
Copy link
Contributor Author

@abhilash1in Can you do a rebase?

On it. Resolving merge conflicts. Should be done soon.

@kaxil
Copy link
Member

kaxil commented Nov 17, 2020

You might also have to update alembic revision ids

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@abhilash1in
Copy link
Contributor Author

abhilash1in commented Nov 18, 2020

@kaxil @mik-laj can you please take a look at the failing workflow? Not sure why there is an error Error: read ECONNRESET in Upload artifact for coverage step.

@mik-laj
Copy link
Member

mik-laj commented Nov 18, 2020

@abhilash1in Please ignore it. This is just a transistent problem. This should be fixed soon.

@abhilash1in
Copy link
Contributor Author

@kaxil @mik-laj All checks passed. Rebased again to latest master. Waiting for checks to run again. Please feel free to rebase again if required and please merge this PR as early as possible.

@kaxil kaxil merged commit bf6da16 into apache:master Nov 18, 2020
@abhilash1in abhilash1in deleted the add-connection-description branch November 18, 2020 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLI area:webserver Webserver related Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants