Skip to content

fix(bigtable): improve alternate universe support - #19192

Open
daniel-sanche wants to merge 9 commits into
mainfrom
b588992371_universe_validation
Open

daniel-sanche wants to merge 9 commits into
mainfrom
b588992371_universe_validation

Conversation

@daniel-sanche

@daniel-sanche daniel-sanche commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Improves support for non-default universes:

  • data client:
    • disables client-side metrics when running against a custom endpoint
    • only sends relevent client options to Metrics Client
  • legacy client:
    • adds _inherit_admin_client_options to read universe_domain from admin_client_options, then client_options, then environment variable, and uses it to populate api_endpoint
    • adds _resolve_admin_endpoint to resolve the admin channel host from self._admin_client_options (api_endpoint or universe_domain)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chalmerlowe

chalmerlowe commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for working on this.

Looking closer at _resolve_admin_endpoint — really nice catch on the 6-step precedence rule (admin.api_endpoint -> admin.universe_domain -> client.api_endpoint -> client.universe_domain -> env -> default, where an explicit child universe_domain blocks inheriting the parent's api_endpoint). I just folded that exact parent_api_endpoint precedence rule into inherit_universe_in_client_options in #19211 so Compute Extended Operations and other sub-clients get the same behavior!

If you'd like to lean on the shared google.api_core.universe helpers as you finish #19192, they also cover four additional cases out of the box (note: since Bigtable's constraints-3.10.txt pins google-api-core==2.28.0, compare_domains and get_api_endpoint should be importable directly today, while the #19211 helpers can be copy-pasted from the links below with a # TODO(universe-domain): use until Bigtable's minimum google-api-core floor exceeds 2.44.0) comment:

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 self._credentials while exempting None and AnonymousCredentials and raising standard UniverseMismatchError — which covers both BigtableDataClient (data/_sync_autogen/client.py:198 & data/_async/client.py:265, where if credentials currently skips ADC when credentials=None) and legacy bigtable.Client (client.py, which currently doesn't validate self._credentials on admin=True channels while GAPIC _validate_universe_domain() is stubbed out).

mTLS guard in non-default universes — universe.get_api_endpoint (available in 2.28.0 today) + resolve_client_universe (#19211): Pairing resolve_client_universe with universe.get_api_endpoint keeps EmptyUniverseError validation ahead of api_endpoint overrides while also raising MutualTLSChannelError if GOOGLE_API_USE_MTLS_ENDPOINT="always" is set in a custom universe.

Oldest-constraint credential stub for unit tests (google-auth==2.14.1) — _StubCredentials (#19211): Subclasses google.auth.credentials.Credentials with a read-only universe_domain property so custom-universe unit tests run across all constraint files without mutating AnonymousCredentials or needing pytest.skip.

@daniel-sanche

Copy link
Copy Markdown
Contributor Author

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

@daniel-sanche daniel-sanche changed the title [DRAFT] fix(bigtable): improve alternate universe support fix(bigtable): improve alternate universe support Nov 26, 2026
@daniel-sanche
daniel-sanche marked this pull request as ready for review November 26, 2026 00:44
@daniel-sanche
daniel-sanche requested a review from a team as a code owner November 26, 2026 00:44
# 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_universe on validate_credentials_universe in catalog.py (cl/1029785586) so google.auth.aio.credentials.AnonymousCredentials is also exempted (needed for BigtableDataClientAsync in custom universes).

  • Update _inherit_admin_client_options to match inherit_universe_in_client_options in catalog.py (cl/1029785586) so an explicit "googleapis.com" on the parent overrides GOOGLE_CLOUD_UNIVERSE_DOMAIN and prevents child admin clients from drifting.
    Keep the # TODO(universe-domain): markers until testing/constraints-3.10.txt exceeds google-api-core 2.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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants