PCTEJA commented on code in PR #77376:
URL: https://github.com/apache/airflow/pull/77376#discussion_r4655281928
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -77,8 +80,46 @@ def get_fs(conn_id: str | None, storage_options: dict[str,
Any] | None = None) -
# is the storage account name rather than part of an account URL.
options["account_name"] = account_name
elif conn_type != "adls" or conn.host or not tenant_id:
- # WASB, full-URL, and custom-endpoint connections keep the historical
account_url path.
- options["account_url"] = parse_blob_account_url(conn.host, conn.login)
+ # adlfs has no account_url parameter and would silently drop it; it
reads
+ # account_name and builds the URL from account_host, so derive both
from
+ # the account URL. Only an endpoint host (a hostname with a dot, the
same
+ # parsing _bare_account_name_from_host uses) supplies an account_host,
+ # and only when it is not the default blob host, which adlfs already
+ # defaults to: a bare identifier is not an endpoint, and for those
+ # parse_blob_account_url builds the URL from the login. A bare login is
+ # the account name (wasb shared key), but with a tenant id the login
is a
+ # service principal client id, so without an endpoint host nothing is
+ # derived and adlfs falls back to account_name from extras or the
+ # AZURE_STORAGE_ACCOUNT_NAME env var.
+ conn_hostname = _hostname_from_host(conn.host)
+ host_is_endpoint = conn_hostname is not None and "." in conn_hostname
+ if host_is_endpoint or (conn.login and not tenant_id):
+ account_url = urlparse(parse_blob_account_url(conn.host,
conn.login))
Review Comment:
Fixed in d09a354d, account from hostname
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -77,8 +80,46 @@ def get_fs(conn_id: str | None, storage_options: dict[str,
Any] | None = None) -
# is the storage account name rather than part of an account URL.
options["account_name"] = account_name
elif conn_type != "adls" or conn.host or not tenant_id:
- # WASB, full-URL, and custom-endpoint connections keep the historical
account_url path.
- options["account_url"] = parse_blob_account_url(conn.host, conn.login)
+ # adlfs has no account_url parameter and would silently drop it; it
reads
+ # account_name and builds the URL from account_host, so derive both
from
+ # the account URL. Only an endpoint host (a hostname with a dot, the
same
+ # parsing _bare_account_name_from_host uses) supplies an account_host,
+ # and only when it is not the default blob host, which adlfs already
+ # defaults to: a bare identifier is not an endpoint, and for those
+ # parse_blob_account_url builds the URL from the login. A bare login is
+ # the account name (wasb shared key), but with a tenant id the login
is a
+ # service principal client id, so without an endpoint host nothing is
+ # derived and adlfs falls back to account_name from extras or the
+ # AZURE_STORAGE_ACCOUNT_NAME env var.
+ conn_hostname = _hostname_from_host(conn.host)
+ host_is_endpoint = conn_hostname is not None and "." in conn_hostname
+ if host_is_endpoint or (conn.login and not tenant_id):
+ account_url = urlparse(parse_blob_account_url(conn.host,
conn.login))
+ derived_account_name = account_url.hostname.split(".")[0] if
account_url.hostname else None
+ if derived_account_name:
+ options["account_name"] = derived_account_name
+ if host_is_endpoint and account_url.netloc:
+ # adlfs is a Blob client, so an Azure Data Lake (dfs) endpoint
is
+ # mapped back to its blob form before it can become the
+ # account_host. Only a standard Azure endpoint is mapped (a dfs
+ # label in front of a core label and an Azure suffix); a custom
+ # domain is kept as is. The host is lowercased first, as
+ # hostnames are case-insensitive and urlparse only lowercases
+ # .hostname, and an explicit port is carried over unchanged.
+ netloc_host, colon, netloc_port =
account_url.netloc.lower().rpartition(":")
+ if not colon or not netloc_port.isdigit():
+ netloc_host, netloc_port = account_url.netloc.lower(), ""
+ account_host_labels = netloc_host.split(".")
+ if account_host_labels[1:3] == ["dfs", "core"] and
".".join(account_host_labels[3:]) in {
Review Comment:
Fixed in d09a354d, dfs mapping broadened
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]