Add BigLake configuration validation for catalog creation and updates - #5196
Add BigLake configuration validation for catalog creation and updates#5196davidchaava wants to merge 9 commits into
Conversation
|
Hi @sungwy , We would especially appreciate your feedback from the GCP/BigLake compatibility perspective. Thank you. |
| Pattern.compile("^[A-Za-z0-9._-]+$"); | ||
| private static final Pattern GCS_SERVICE_ACCOUNT_PATTERN = | ||
| Pattern.compile( | ||
| "^[a-z][a-z0-9-]{4,28}[a-z0-9]@[a-z][a-z0-9-]{4,28}[a-z0-9]\\.iam\\.gserviceaccount\\.com$"); |
There was a problem hiding this comment.
This only accepts the user-managed SA form, so it rejects the Compute-default (…-compute@developer.gserviceaccount.com) and App-Engine-default (@appspot.gserviceaccount.com) SAs which are both valid impersonation targets. GCP's generateAccessToken accepts any SA email, and Polaris' own GcpCredentialsStorageIntegration only checks presence, so this check is stricter than both. Could we accept any valid SA email, or, if the restriction's intentional, reword the error (those defaults are Google SA emails)? WDYT
There was a problem hiding this comment.
Good catch! That restriction wasn’t intentional. I’ve relaxed the check so it no longer assumes the user-managed service account format, and added coverage for Compute Engine and App Engine default service accounts. GCP remains the source of truth for whether the account exists and can be impersonated.
Thanks!
5a981c8 to
b9898f5
Compare
b9898f5 to
9127394
Compare
sungwy
left a comment
There was a problem hiding this comment.
Thanks @davidchaava
I took another pass and added a few more review comments. Please let me know when you've taken another pass so I can submit the CI run
| * polaris catalogs list | ||
| """ | ||
|
|
||
| _GCP_QUOTA_PROJECT_PROPERTY = "header.x-goog-user-project" |
There was a problem hiding this comment.
I think it'd make more sense to move this into constants.py. WDYT?
https://github.com/apache/polaris/blob/main/client/python/apache_polaris/cli/constants.py
There was a problem hiding this comment.
Moved GCP_QUOTA_PROJECT_PROPERTY to constants.py
| || connectionConfig.getAuthenticationParameters().getAuthenticationType() | ||
| != AuthenticationParameters.AuthenticationTypeEnum.GCP) { | ||
| return; |
There was a problem hiding this comment.
I'm a bit confused here. In the federation docs, it says that only Implicit authentication type is supported against BigQuery Metastore. Could we double check this is correct?
https://polaris.apache.org/releases/1.7.0/federation/bigquery-metastore-federation/
There was a problem hiding this comment.
Thanks for checking. This validator targets ICEBERG_REST catalogs using GCP authentication against the BigLake REST endpoint. BigQuery Metastore federation uses the separate BIGQUERY connection type and remains IMPLICIT-only. I added a comment clarifying this distinction.
There was a problem hiding this comment.
Is this the right place for this validator?
BigQuery Metastore was renamed by Google as Lakehouse Catalog.
I believe in Apache Polaris, code was committed while BigQuery Metastore was the name used by Google.
Shall we put this module into the right path, where BigQuery Metastore related code already exists?
https://github.com/apache/polaris/tree/main/extensions/federation/bigquery
There was a problem hiding this comment.
Thanks for raising this. We plan to keep the validator in the admin service because it validates Management API create/update requests for external ICEBERG_REST catalogs targeting the BigLake REST endpoint.
The existing extensions/federation/bigquery module handles the separate optional BIGQUERY connection type for BigQuery Metastore/Lakehouse Catalog federation. Moving this validator there would couple BigLake REST validation to that optional extension and would not cover the actual catalog type used here.
The distinction is reflected in the validator code:
https://github.com/akvelon/polaris/blob/0348c24ace995f90cba72760a95457560f247f5c/runtime/service/src/main/java/org/apache/polaris/service/admin/BigLakeCatalogValidator.java#L61-L87
| throw new IllegalArgumentException( | ||
| "Invalid BigLake connectionConfigInfo.properties entry '" | ||
| + propertyName | ||
| + "': only '" | ||
| + QUOTA_PROJECT_HEADER | ||
| + "' is supported."); |
There was a problem hiding this comment.
Question: Is there a reason why we block other headers in addition to BLOCKED_HEADER_PROPERTIES?
I think from an API perspective, having an allowlist of headers we support is easier to support and evolve safely with. If that's the intention, I'd want to make sure we are supporting all headers we want in this PR
There was a problem hiding this comment.
Yes, this is intentional. For BigLake catalog configuration, Polaris supports only header.x-goog-user-project in connectionConfigInfo.properties. Authorization and credential-vending headers are managed by Polaris and must not be overridden through catalog configuration.
I made the allowlist explicit as SUPPORTED_HEADER_PROPERTIES and added a regression test for unsupported headers:
| Pattern.compile("^[a-z][a-z0-9-]{4,28}[a-z0-9]$"); | ||
| private static final Pattern GCP_PROJECT_NUMBER_PATTERN = Pattern.compile("^[1-9][0-9]{5,}$"); | ||
| private static final Pattern BIGLAKE_URI_CATALOG_PATTERN = | ||
| Pattern.compile("^/[1-9][0-9]{5,}/catalogs/[^/\\s]+$"); |
There was a problem hiding this comment.
I'm not sure if this is correct.
In the docs, it says the warehouse URL is: bl://projects/PROJECT_ID/catalogs/LAKEHOUSE_CATALOG_ID
Where PROJECT_ID is an alphanumeric ID that matches line 44-45 above:
private static final Pattern GCP_PROJECT_ID_PATTERN =
Pattern.compile("^[a-z][a-z0-9-]{4,28}[a-z0-9]$");
There was a problem hiding this comment.
Thank you. The validator now accepts both GCP project IDs and project numbers in the bl://projects/... warehouse URI. I also added regression coverage for the project ID form in commit 0348c24.
Updated implementation:
https://github.com/akvelon/polaris/blob/0348c24ace995f90cba72760a95457560f247f5c/runtime/service/src/main/java/org/apache/polaris/service/admin/BigLakeCatalogValidator.java#L304-L326
8ed4eba to
ece243e
Compare
ece243e to
5be34bd
Compare
|
Hi @sungwy, I’ve gone through your comments and addressed them. Could you please take another look when you have a chance? Thanks! |
Summary
Adds fail-fast validation for BigLake Iceberg REST external catalog configurations during catalog creation and update.
Validation is scoped to GCP-authenticated Iceberg REST catalogs that target the official BigLake endpoint,
https://biglake.googleapis.com/iceberg/v1/restcatalog. Other GCP-authenticated Iceberg REST catalogs retain their existing behavior.Changes
bl://projects/<project-number>/catalogs/<catalog-id>.header.x-goog-user-projectquota-project header.header.x-goog-user-projectinconnectionConfigInfo.propertiesfor new GCP Iceberg REST catalogs.Validation
./gradlew :polaris-runtime-service:test --tests org.apache.polaris.service.admin.BigLakeCatalogValidatorTestpytest tests/test_catalogs_command.py::TestCatalogsCommand::test_external_catalog_gcp -qRelated to #5195