Repository navigation
fix(bigtable): improve alternate universe support - #19192
daniel-sanche wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Bigtable client to properly resolve admin endpoints and universe domains, establishing a clear precedence order between client options, admin client options, and environment variables. It also ensures that the BigtableMetricsExporter is disabled when a custom API endpoint is set or when the client is configured outside the default Google Cloud universe. Comprehensive unit tests have been added to validate these changes. I have no further feedback to provide as there are no review comments.
|
Thanks for working on this. Looking closer at If you'd like to lean on the shared Parent-to-child option inheritance + GAPIC transport= credential clearing — inherit_universe_in_client_options (#19211): Covers all 6 precedence tiers (parent_api_endpoint=...), preserves explicit "googleapis.com" parents when GOOGLE_CLOUD_UNIVERSE_DOMAIN is set in os.environ, and clear_credentials=True clears leftover credentials_file / api_key fields on the copy so passing pre-built transport= in table_admin_client / instance_admin_client (client.py:320, 357) never hits GAPIC's ValueError("When providing a transport instance, provide its credentials directly."). ADC + explicit credential validation (UniverseMismatchError) — validate_credentials_universe (#19211) (backed by existing universe.compare_domains): Validates resolved mTLS guard in non-default universes — universe.get_api_endpoint (available in 2.28.0 today) + resolve_client_universe (#19211): Pairing Oldest-constraint credential stub for unit tests (google-auth==2.14.1) — _StubCredentials (#19211): Subclasses |
|
Thanks for taking a look Chalmer. I will definitely look at the shared helpers to see what we can use here. Note that this legacy bigtable client might be a bit of a special case, since it's a wrapper that delegates to two internal clients, each of which can be configured separately. My hope is to keep the wrapper logic small, and let the internal client logic do most of the work. I'll have to check how the helpers fit in with this model |
| # TODO(universe-domain): Replace with | ||
| # google.api_core.universe.validate_credentials_universe once minimum | ||
| # google-api-core version exceeds 2.44.0. | ||
| def _validate_credentials_universe( |
There was a problem hiding this comment.
SYNC WARNING:
I noticed two sync gaps between #19192 and the proposed shared helpers in catalog.py (cl/1029785586). I recommend the following actions:
-
Mirror
_validate_credentials_universeonvalidate_credentials_universeincatalog.py(cl/1029785586) sogoogle.auth.aio.credentials.AnonymousCredentialsis also exempted (needed forBigtableDataClientAsyncin custom universes). -
Update
_inherit_admin_client_optionsto matchinherit_universe_in_client_optionsincatalog.py(cl/1029785586) so an explicit"googleapis.com"on the parent overridesGOOGLE_CLOUD_UNIVERSE_DOMAINand prevents child admin clients from drifting.
Keep the# TODO(universe-domain):markers untiltesting/constraints-3.10.txtexceedsgoogle-api-core2.44.0.
I know that you have better context on this than I do, so if any of these suggestions are wrong, please leave a comment here. Gemini will pick them up and learn from them during the next sync sweep.
Improves support for non-default universes:
_inherit_admin_client_optionsto read universe_domain from admin_client_options, then client_options, then environment variable, and uses it to populate api_endpoint_resolve_admin_endpointto resolve the admin channel host fromself._admin_client_options(api_endpointoruniverse_domain)