Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for REST transport in Dataproc control-plane calls, controlled via the new MANAGED_SPARK_CONNECT_DATAPROC_TRANSPORT environment variable. It updates client initialization, enhances error handling to parse REST JSON error payloads, and updates the test suite to cover these changes. Feedback is provided regarding a potential issue in HTTP header parsing where a case-sensitive dictionary lookup for 'content-type' might fail if the header is capitalized as 'Content-Type'.
f4afb37 to
9d2d102
Compare
tim-u
left a comment
There was a problem hiding this comment.
CI now exports GOOGLE_CLOUD_DATAPROC_API_ENDPOINT="" on every lane. Any code outside this diff that still uses os.getenv("GOOGLE_CLOUD_DATAPROC_API_ENDPOINT", default) would therefore get "". Have all uses moved to _dataproc_api_endpoint, and do all *ControllerClient( constructions pass the transport? grep -rn "GOOGLE_CLOUD_DATAPROC_API_ENDPOINT|ControllerClient(" google/ would confirm
9d2d102 to
6e2028b
Compare
|
[Dave's coding agent] Verified
All other review comments have been addressed in |
6e2028b to
50f48ba
Compare
Summary
Adds
MANAGED_SPARK_CONNECT_DATAPROC_TRANSPORT(grpcdefault, orrest) so Dataproc control-plane calls (SessionControllerClientandSessionTemplateControllerClient) can use HTTP/REST instead of gRPC.Rationale
In restricted egress environments that allowlist per domain (for example
dataproc.googleapis.comand*.dataproc.googleusercontent.com) without supporting partial-label wildcards for regional subdomains (*-dataproc.googleapis.com), Dataproc gRPC calls to the globaldataproc.googleapis.comendpoint are rejected (Region '...' specified in request does not match endpoint region 'global'), whereas REST requests todataproc.googleapis.comroute by URI path (/v1/projects/*/locations/<region>/*) to the regional backend. SettingMANAGED_SPARK_CONNECT_DATAPROC_TRANSPORT=restalongsideGOOGLE_CLOUD_DATAPROC_API_ENDPOINT=dataproc.googleapis.comallows the client to run in those environments.Changes
session.py):MANAGED_SPARK_CONNECT_DATAPROC_TRANSPORT(grpcorrest, case-insensitive; invalid values raiseValueError).transport="rest"into_create_session_controller_client()(and its_CLIENT_CACHEkey, omitting the kwarg for defaultgrpc) andBuilder.session_template_controller_client.GOOGLE_CLOUD_DATAPROC_API_ENDPOINT=""as unset so it falls back to{region}-dataproc.googleapis.com.session.py):google.api_core.exceptions.from_http_response()parent HTTP classes (BadRequest,Forbidden,NotFound,Conflict) in__createandterminate_s8s_session(checking JSONerror.statusforFAILED_PRECONDITION/ABORTEDso unrelated 400/409 errors still propagate)._extract_api_error_details()to parse JSONdicterror details (fieldViolations) in addition to protobuf objects, stripped REST's<METHOD> <URL>:message prefix in_format_create_session_error(), and detected non-JSON HTML 404s from nonexistent regional endpoints.tests/unit/test_dataproc.py,tests/unit/test_session.py,tests/unit/test_integration_conftest.py).tests/integration/conftest.py,tests/integration/test_session.py).control_planepytest marker (pyproject.toml) and a dedicatedubuntu-latest, restCI lane (.github/workflows/integration-tests.yaml) running-m control_planewithMANAGED_SPARK_CONNECT_DATAPROC_TRANSPORT=restandGOOGLE_CLOUD_DATAPROC_API_ENDPOINT=dataproc.googleapis.com.MANAGED_SPARK_CONNECT_DATAPROC_TRANSPORTinREADME.md.Verification
pyink --check google/ tests/ setup.py: passedpytest -n 8 tests/unit): 817 passed, 17 skippedgoogle.com:hadoop-cloud-dev/us-east4,MANAGED_SPARK_CONNECT_DATAPROC_TRANSPORT=rest,GOOGLE_CLOUD_DATAPROC_API_ENDPOINT=dataproc.googleapis.com):-m control_plane: 6 passed, 12 deselected (1m54s)