Repository navigation
Conversation
Once the installed databricks-sql-kernel supports SOCKS, use_kernel=True connections honor socks4/socks4a/socks5/socks5h URLs in HTTPS_PROXY, or in ALL_PROXY when HTTPS_PROXY is unset, with NO_PROXY bypass, through the kernel's existing environment-proxy handling. The connector needs no code change for this. Record it in CONNECTION_PARAMETERS.md as a documented difference from Thrift: the variables honored, DNS per scheme (socks5/socks4 resolve locally, socks5h/socks4a at the proxy), credentials as URL userinfo, fail-closed behavior, and that Thrift raises ProxySchemeUnknown for a SOCKS HTTPS_PROXY and ignores ALL_PROXY. Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Description
On the Thrift backend, SOCKS proxies don't work: a
socks5h://HTTPS_PROXYfails with urllib3'sProxySchemeUnknown, andALL_PROXYis ignored. With today's kernel release,use_kernel=Truefails closed for any SOCKS URL. The kernel SOCKS change (databricks/databricks-sql-kernel, candidatef4826ba16c8d460e4018f5b7de4d820c9a604d4a) adds SOCKS support to the kernel's existing environment-proxy handling, so with that kernel the connector's kernel path honors SOCKS proxies from the environment with no connector code change.This PR documents that in
CONNECTION_PARAMETERS.mdas a recorded difference from Thrift. It adds a "SOCKS proxies from environment variables" section and one line in the "Supported on Kernel, missing / ignored on Thrift" gap list. The section covers:HTTPS_PROXY, thenALL_PROXYwhenHTTPS_PROXYis unset, withNO_PROXYbypass;socks4,socks4a,socks5,socks5h; baresocks://is rejected);socks5/socks4resolve locally,socks5h/socks4aat the proxy;ProxySchemeUnknownfor a SOCKSHTTPS_PROXY,ALL_PROXYignored).No connector code, option, default or guard changes. Feature:
socks-proxy. No ADBC-specific changes.How is this tested?
sql.connectAPI with a locally built kernel wheel)Acceptance
use_kernel=TrueandHTTPS_PROXY=socks5h://…,SELECT 1returns 1 and closes cleanly on both engines. The backend object isKernelDatabricksClient, and the fixture relayed the warehouse connection.socks5handsocks4asend the warehouse host as a domain;socks5andsocks4send an IPv4 address (DBSQL: all four; Reyden: socks5h, socks4a, socks5).user:password@pair in the URL passes on both engines. A wrong pair fails withSOCKS error: credentials not accepted, with no retry without credentials and no direct connection.error connecting to socks proxyand nothing reaches the warehouse. That took about 17 s with_retry_stop_after_attempts_count=1, and 103 s (6 attempts) under the default retry policy. A dead proxy on a CloudFetch query fails the same way.NO_PROXY=<warehouse host>connects directly on both engines;NO_PROXY=.databricks.comconnects directly on DBSQL. With a host-onlyNO_PROXYon the 200,000-row CloudFetch query, the warehouse connection goes direct while the storage-host downloads still go through the proxy, because they are not matched.range()query downloads every storage chunk through the proxy, with the same address type as the workspace connection (domain forsocks5h, IPv4 forsocks5). Row counts are exact on DBSQL and Reyden.HTTPS_PROXYandALL_PROXYeach route through the proxy, andHTTPS_PROXYwins over a deadALL_PROXY. In the same session, Thrift fails withProxySchemeUnknownfor a SOCKSHTTPS_PROXYand ignoresALL_PROXY, connecting directly.687029ab4b8ce2db5456941ce683a200e71606d0.Baseline and target validation
ThriftDatabricksClient)f4826ba(KernelDatabricksClient)SELECT 1;ALL_PROXYonly;HTTPS_PROXYbeatsALL_PROXY; userinfo ok/bad; dead proxy (1 attempt, default retry, CloudFetch);NO_PROXYhost/suffix; CloudFetch 200k socks5h/socks5/NO_PROXYhost; direct control; ThriftHTTPS_PROXYandALL_PROXYProxySchemeUnknownforHTTPS_PROXY;ALL_PROXYignored (direct)HTTPS_PROXYfails client-side withProxySchemeUnknown. WithALL_PROXY, Thrift goes direct, is rejected (KP001) and the connector recovers onto the kernel:unsupported, standing deviation RE-16039KernelDatabricksClient)ALL_PROXYonly;HTTPS_PROXYbeatsALL_PROXY; userinfo ok/bad; dead proxy;NO_PROXYhost; CloudFetch 200k socks5h; direct controlEvery positive row ran behind a controlled loopback SOCKS4/4a/5 fixture with
--require-proxy, so a pass the fixture did not relay would count as a failure. The fixture records SOCKS version, address type and RFC 1929 result. The probe reports the effective transport from the connection's backend object and records the loaded kernel binary's hash, which matched the locally built wheel on every row.Hermetic tests:
pytest tests/unit -m "not realkernel"(1413 passed, 4 skipped),pytest tests/unit/test_session.py -m realkernelagainst the candidate kernel wheel (2 passed),pytest tests/unit/test_kernel_async_readers.py -m realkernel(6 passed), andblack src --check(clean).Bounded performance comparison: connect + open session +
SELECT 1+ fetch + close, one fresh process per sample, kernel direct vs kernelHTTPS_PROXY=socks5h. Each pair had 1 warm-up plus 5 samples, interleaved and run sequentially with no other live cases. The agreed tolerance is a SOCKS median within max(+25 %, +150 ms) of the direct median.Both are within tolerance. The fixture is a single-threaded Python relay, so its overhead is included.
Nightly coverage: SOCKSPROXY-001..007 and 010 are planned in
databricks-driver-test(specs/socks-proxy.yaml,tests/python/tests/test_socks_proxy.py), run by the existingdatabricks-sql-python-nightly.yml(cron0 3 * * *, kernel/normal and kernel/reyden legs). That is a separate driver-test change. HTTP-proxy no-regression coverage is the existing HTTPPROXY-006..008 (tests/python/tests/test_environment_proxy.py) in the same nightly.Blocked/unsupported cases: Reyden rejects Thrift (KP001), which is the standing deviation RE-16039. It is reported, not counted as a pass.
Related Tickets & Documents
f4826ba16c8d460e4018f5b7de4d820c9a604d4a(unitsocks-proxy--kernel).databricks-sql-kernelrelease that supports SOCKS", so they stay accurate before that release. The published kernel 1.5.0 still rejects SOCKS URLs, so tests against it do not cover this behavior. Moving the[kernel]floor to that release is a separate kernel-upgrade change.KERNEL_REVis not changed here.This pull request and its description were written by Isaac.