Add proxy support to Databricks connections#68527
Conversation
fdd7d60 to
cdfb613
Compare
cdfb613 to
124d736
Compare
|
cc @moomindani @mwojtyczka for review from Databricks team |
Databricks proxy support validation for PR #68527Validated against exact PR head Test suiteFocused Databricks provider tests passed: Command: PYTHONPATH=/Users/nalam/Downloads/airflow-68527-vr/airflow-core/src:/Users/nalam/Downloads/airflow-68527-vr/providers/databricks/src \
/Users/nalam/airflow-1/.venv/bin/python -m pytest \
providers/databricks/tests/unit/databricks/hooks/test_databricks_base.py \
providers/databricks/tests/unit/databricks/hooks/test_databricks.py \
providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py -qLive Databricks validationCreated a one-day personal access token scoped to The live validation used Airflow's {
"proxies": {
"http": "http://127.0.0.1:<port>",
"https": "http://127.0.0.1:<port>"
}
}The validation called Sync path result: Async path result: This covers the PR's sync EvidenceEvidence bundle: https://gist.github.com/Vamsi-klu/fd442d24aec03cd0bae7c6bfc0997e22 Workspace availability: Workspace page: Post-cleanup token state: |
|
Thanks @jroachgolf84 for the approval, @eladkal Can i get a stamp please? Thanks for the time! |
moomindani
left a comment
There was a problem hiding this comment.
Checked the following:
- The
proxiesextra is allowlisted (http/httpsonly) with validation — arbitrary connection extras are not passed through. - Proxy is applied to sync/async REST API calls, Azure AAD credential acquisition (
ClientSecretCredential,DefaultAzureCredential), and Databricks OAuth token exchange. Intentionally excluded from SQL connector kwargs andManagedIdentityCredential(IMDS is a local metadata service). databricks-sdkanddatabricks-sql-connectordo not natively support HTTP proxy configuration, so this connection-extra approach fills a real gap.
One question and one minor item:
- Could the docs clarify the relationship with
HTTP_PROXY/HTTPS_PROXYenvironment variables?requestsandaiohttpalready honor those, so it would help users understand when the explicitproxiesextra is needed — specifically, which paths (e.g. Azure AAD token acquisition via Azure Identity SDK) don't pick up the environment variables and require the explicit setting, and that this extra overrides the environment variables when both are set. - Consider adding a brief comment on why
ManagedIdentityCredentialis excluded from proxy kwargs — the other Azure credential paths receive them, so the asymmetry might confuse a future reader.
Drafted-by: Claude Code (Opus 4.8); reviewed by @moomindani before posting
Clarify which Databricks auth paths honor HTTP_PROXY/HTTPS_PROXY/NO_PROXY (sync requests and Azure Identity) and which do not (the async aiohttp paths), that the proxies extra overrides the environment variables, and why the Azure managed-identity (IMDS) path is never proxied. Add a comment at both ManagedIdentityCredential call sites and a regression test asserting the managed-identity and IMDS metadata calls are not proxied while the Databricks REST call is.
|
Thanks @moomindani for the careful review — both points addressed in the latest commit (58b7c4a).
Also added a regression test asserting ManagedIdentityCredential and the IMDS metadata call are constructed without No changelog/newsfragment: providers don't consume newsfragments, and this is a docs + comment clarification with a test, no behavior change. Re-ran the databricks hook tests (285 passed). Drafted-by: Claude Code (Opus 4.8); reviewed by @Vamsi-klu before posting |
|
Thanks for the correction — you're right that the Azure Identity SDK paths honor the env vars; it's the async Drafted-by: Claude Code (Opus 4.8); reviewed by @moomindani before posting |
|
@moomindani any futher comments or are you approving this PR? |
* Add Databricks connection proxy support * Document Databricks proxies extra relationship with proxy env vars Clarify which Databricks auth paths honor HTTP_PROXY/HTTPS_PROXY/NO_PROXY (sync requests and Azure Identity) and which do not (the async aiohttp paths), that the proxies extra overrides the environment variables, and why the Azure managed-identity (IMDS) path is never proxied. Add a comment at both ManagedIdentityCredential call sites and a regression test asserting the managed-identity and IMDS metadata calls are not proxied while the Databricks REST call is. * Rephrase Databricks proxy docs wording --------- Co-authored-by: Ramachandra Nalam <nalamvamsi13@gmail.com>



Add explicit proxy support for Databricks connections.
What changed
This adds a documented
proxiesconnection extra for the Databricks provider. The extra is intentionally allowlisted and only acceptshttpandhttpskeys, for example:{ "proxies": { "http": "http://proxy.example.com:8080", "https": "http://proxy.example.com:8443" } }The configured proxy is applied to:
Why
Users running Airflow behind a corporate proxy could not authenticate to Azure Databricks because token acquisition to Azure/Databricks endpoints did not receive proxy configuration.
This fixes #32576 while keeping connection extras explicit and safe. The implementation does not pass arbitrary connection extras through to client libraries; it validates and forwards only the reviewed
proxiesextra.Testing
I added coverage for:
proxiesparsing from Databricks connection extrasaiohttpproxyproxiesCommands run:
uv run ruff format providers/databricks/src/airflow/providers/databricks/hooks/databricks_base.py providers/databricks/tests/unit/databricks/hooks/test_databricks.py providers/databricks/tests/unit/databricks/hooks/test_databricks_base.pyuv run ruff check --fix providers/databricks/src/airflow/providers/databricks/hooks/databricks_base.py providers/databricks/tests/unit/databricks/hooks/test_databricks.py providers/databricks/tests/unit/databricks/hooks/test_databricks_base.pyuv run ruff format providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.pyuv run ruff check --fix providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.pyuv run ./scripts/ci/prek/check_new_airflow_exception_usage.py providers/databricks/src/airflow/providers/databricks/hooks/databricks_base.pyuv run --project providers/databricks pytest providers/databricks/tests/unit/databricks/hooks/test_databricks_base.py providers/databricks/tests/unit/databricks/hooks/test_databricks.py providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py -qResult:
284 passed; AirflowException usage check passed.closes: #32576
Was generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-5) following the guidelines
Drafted-by: Codex (GPT-5) (no human review before posting)