Content-Length: 487691 | pFad | https://github.com/apache/airflow/pull/25416

65 Hide unused fields for Amazon Web Services connection by Taragolis · Pull Request #25416 · apache/airflow · GitHub
Skip to content

Hide unused fields for Amazon Web Services connection #25416

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

Merged
merged 3 commits into from
Aug 4, 2022

Conversation

Taragolis
Copy link
Contributor

Follow up #25256

Seems like host, port, schema never used in AWS Connection, disable it in UI.

image

@boring-cyborg boring-cyborg bot added area:providers provider:amazon AWS/Amazon - related issues labels Jul 29, 2022
@Taragolis Taragolis force-pushed the aws-connection-hide-unused-ui-fields branch 2 times, most recently from d97c480 to d44d9c2 Compare August 1, 2022 12:37
@potiuk
Copy link
Member

potiuk commented Aug 2, 2022

@o-nikolas @ferruzzi @vincbeck - WDYT?

@ferruzzi
Copy link
Contributor

ferruzzi commented Aug 2, 2022

Neat. I didn't realize that was an option. I'll have to look into what else that may affect, but I think it's a safe change based on my current understanding. 👍

@vincbeck
Copy link
Contributor

vincbeck commented Aug 2, 2022

Thanks again for doing these changes! I like that. But I agree with @eladkal, I think renaming these fields to access_key and secret_key would be less confusing for the user

@Taragolis
Copy link
Contributor Author

Due to the fact that @vincbeck @eladkal @josh-fell agreed that renaming would be less confusing users I prepared this option.

image

Also one question, do you think it is also required rename Login and Password in documentation?

If everything fine, I will push updates tomorrow.

@vincbeck
Copy link
Contributor

vincbeck commented Aug 2, 2022

Yes please :)

@Taragolis
Copy link
Contributor Author

@gmcrocetti regarding to #25494

Again, my personal thought, I still would suggest to hide host because it never (at least since Airflow 1.9) use in AwsHook. And might be better replace extra['host'] by extra['endpoint_url'] for maintain uniformity with boto3.client and boto3.resource.

Couple month ago I've also played with extra fields in UI, by same way as it implemented in SnowflakeHook
image

@staticmethod
def get_connection_form_widgets() -> Dict[str, Any]:
"""Returns connection widgets to add to connection form"""
from flask_appbuilder.fieldwidgets import BS3TextAreaFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import BooleanField, StringField
return {
"extra__snowflake__account": StringField(lazy_gettext('Account'), widget=BS3TextFieldWidget()),
"extra__snowflake__warehouse": StringField(
lazy_gettext('Warehouse'), widget=BS3TextFieldWidget()
),
"extra__snowflake__database": StringField(lazy_gettext('Database'), widget=BS3TextFieldWidget()),
"extra__snowflake__region": StringField(lazy_gettext('Region'), widget=BS3TextFieldWidget()),
"extra__snowflake__role": StringField(lazy_gettext('Role'), widget=BS3TextFieldWidget()),
"extra__snowflake__private_key_file": StringField(
lazy_gettext('Private key (Path)'), widget=BS3TextFieldWidget()
),
"extra__snowflake__private_key_content": StringField(
lazy_gettext('Private key (Text)'), widget=BS3TextAreaFieldWidget()
),
"extra__snowflake__insecure_mode": BooleanField(
label=lazy_gettext('Insecure mode'), description="Turns off OCSP certificate checks"
),
}

However I stoped by couple reasons:

  1. AwsHook at that moment had a lot of ways to did the same things.
  2. All custom fields stored in Connection['extra'] as extra__{conn_type}__{field_name} in this case we need also care about some funny cases such as:
Connection(
    conn_id="aws_conn_hell",
    conn_type="aws",
    extra={
        "region_name": "us-east-1",
        "extra__aws__region_name": "eu-west-1",
        "session_kwargs": {
             "region_name": "cn-north-1",
        }
    }
)
  1. Right now BaseSessionFactory supports custom SAML auth and WebIdentity by Google and both of them also have their own attributes in Connection['extra']

So I would suggest to make AwsHook and BaseSessionFactory use only generic fields in Connection, make easier way to add custom federation Auth and only after that we may add additional fields in the UI

@Taragolis Taragolis force-pushed the aws-connection-hide-unused-ui-fields branch from d44d9c2 to baf87ec Compare August 3, 2022 14:07
@Taragolis Taragolis requested a review from mik-laj as a code owner August 3, 2022 14:07
@Taragolis
Copy link
Contributor Author

Update for review.

Seems like errors in CI not related to this PR

Copy link
Contributor

@ferruzzi ferruzzi left a comment

Choose a reason for hiding this comment

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

Overall, I like it. Left a couple of small suggestions, but no blocking fixes. 👍

)

# Generate Environment Variable Name and Connection URI
env_key, conn_uri = f"AIRFLOW_CONN_{conn.conn_id.upper()}", conn.get_uri()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, is there a reason these two assignments are on the same line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh... No reason. Just a copy-paste from my personal scratch file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't particularly hate it, and I know it's functionally the same thing, it's just not something I see in this codebase so I tend to avoid it for style consistency, that's all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think good use case is unpack from tuple but not in this situation. Thanks for mention

@@ -104,6 +104,33 @@ If you are configuring the connection via a URI, ensure that all components of t
Examples
--------

Copy link
Contributor

Choose a reason for hiding this comment

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

🥇 Nice addition

@Taragolis Taragolis force-pushed the aws-connection-hide-unused-ui-fields branch from baf87ec to 7d5e7ff Compare August 3, 2022 19:16
Copy link
Contributor

@vincbeck vincbeck left a comment

Choose a reason for hiding this comment

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

LGTM. Again, thanks for all these changes!

@josh-fell
Copy link
Contributor

Again, my personal thought, I still would suggest to hide host because it never (at least since Airflow 1.9) use in AwsHook. And might be better replace extra['host'] by extra['endpoint_url'] for maintain uniformity with boto3.client and boto3.resource.

Sounds reasonable. As part of #25494, host could simply be renamed to endpoint_url and the placeholder in Extra for host and just be moved up accordingly should that PR be something that should be implemented. I'll defer to you all with this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:amazon AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/apache/airflow/pull/25416

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy