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

Refactor account_url use in WasbHook #32980

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

ephraimbuddy
Copy link
Contributor

@ephraimbuddy ephraimbuddy commented Jul 31, 2023

This PR moves the account_url setting to one place.
Tested this by making connection to azure using the different methods, however, I was not able to connect using
the tenant_id in the extra field. This looks like a bug because ClientSecretCredential is not among the credentials
to use in BlobServiceClient. The credentials to use include AzureNamedKeyCredential,AzureSasCredential,AsyncTokenCredential.
So this will need special debugging.

@pankajkoti
Copy link
Member

cc: @manmeetkaur

This PR moves the account_url setting to one place.
Tested this by making connection to azure using the different methods, however, I was not able to connect using
the tenant_id in the extra field. This looks like a bug because ClientSecretCredential is not among the credentials
to use in BlobServiceClient. The credentials to use include AzureNamedKeyCredential,AzureSasCredential,AsyncTokenCredential.
So this will need special debugging.
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.

LGTM

@@ -184,15 +184,19 @@ def get_conn(self) -> BlobServiceClient:
# connection_string auth takes priority
return BlobServiceClient.from_connection_string(connection_string, **extra)

account_url = (
Copy link
Contributor

Choose a reason for hiding this comment

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

That ended up still looking pretty gnarly, didn't 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.

Yeah but quite understandable

@ephraimbuddy ephraimbuddy merged commit df74553 into apache:main Aug 2, 2023
42 checks passed
@ephraimbuddy ephraimbuddy deleted the refactor-account-url branch August 2, 2023 06:14
ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Aug 17, 2023
There are different ways users supply the hostname(account url) in azure,
sometimes the host doesn't have a urlparse.scheme but has urlparse.path e.g name.blob.windows.net
and other times, it will just be Azure ID e.g aldhjf9dads.
While working on apache#32980, I assumed that if there's no scheme, then the hostname is not valid, that's
incorrect since DNS can serve as the host.
The fix was to check if we don't have netloc and that urlparse.path does not include a dot and if it does not, use the login/account_name to construct
the account_url
ephraimbuddy added a commit that referenced this pull request Aug 17, 2023
* Fix updating account url for WasbHook

There are different ways users supply the hostname(account url) in azure,
sometimes the host doesn't have a urlparse.scheme but has urlparse.path e.g name.blob.windows.net
and other times, it will just be Azure ID e.g aldhjf9dads.
While working on #32980, I assumed that if there's no scheme, then the hostname is not valid, that's
incorrect since DNS can serve as the host.
The fix was to check if we don't have netloc and that urlparse.path does not include a dot and if it does not, use the login/account_name to construct
the account_url

* fixup! Fix updating account url for WasbHook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants