You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "diqiu50 (via GitHub)" <gi...@apache.org> on 2026/08/21 10:16:30 UTC
[PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
diqiu50 opened a new pull request, #12555:
URL: https://github.com/apache/gravitino/pull/12555
### What changes were proposed in this pull request?
The Trino connector builds an internal Iceberg REST catalog pointing at the Gravitino Iceberg REST server for every `lakehouse-iceberg` catalog, instead of translating `catalog-backend` into Trino's `jdbc` or `hive_metastore` catalog type.
Three connector-level properties, configured once per Trino cluster:
- `gravitino.iceberg.rest-enabled` (default `true`)
- `gravitino.iceberg.rest-uri`
- `gravitino.iceberg.rest-catalog.` — prefix rewritten to `iceberg.rest-catalog.`, carrying the IRC's authentication
Everything else is derived from the catalog. A catalog with `catalog-backend=rest` is not re-routed.
### Why are the changes needed?
`credential-providers=s3-token` is silently non-functional on this path.
Fix: #12554
### Does this PR introduce _any_ user-facing change?
Yes. Three new connector properties, and a breaking change: `gravitino.iceberg.rest-enabled` defaults to `true`, so on upgrade a metalake with `catalog-backend=jdbc` or `hive` Iceberg catalogs fails to load them unless `gravitino.iceberg.rest-uri` is set, or the switch is turned off. Needs a release note.
Docs updated under `docs/trino-connector/`.
### How was this patch tested?
Unit tests: 148 pass, 13 new.
Integration test: the existing `lakehouse-iceberg` testset runs over the new path, 24/24 pass across a hive-backend and a jdbc-backend catalog.
Not verified: end-to-end s3-token vending. The test warehouse is HDFS, which skips credential generation, so no STS credential is actually issued. This needs a real AWS account.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3843679567
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java:
##########
@@ -152,6 +246,99 @@ private Map<String, String> buildJDBCBackendProperties(Map<String, String> prope
return jdbcProperties;
}
+ private void warnOnReservedOverrides(GravitinoCatalog catalog, Map<String, String> config) {
+ for (String reserved : RESERVED_REST_PROPERTIES) {
+ if (config.containsKey(reserved)) {
+ LOG.info(
+ "Property '{}' set on catalog '{}' is ignored; the connector always derives it when "
+ + "routing through the Iceberg REST server.",
+ reserved,
+ catalog.getName());
+ }
+ }
+ }
+
+ /**
+ * Derives the Trino file system config from the catalog's warehouse location. Vended credentials
+ * are only consumed by Trino's native file systems, so the native implementation matching the
+ * warehouse scheme has to be enabled.
+ */
+ private Map<String, String> buildStorageProperties(Map<String, String> properties) {
+ Map<String, String> storageProperties = new HashMap<>();
+ // Always available as the fallback; where a native file system is also enabled below, that one
+ // takes precedence for its own scheme.
+ storageProperties.put(TRINO_FS_HADOOP_ENABLED, "true");
+
+ String warehouse = properties.get(IcebergConstants.WAREHOUSE);
Review Comment:
Native filesystem selection is based only on the catalog warehouse, but credentials are vended per table location. A valid Hive catalog may have no warehouse, or an HDFS warehouse with a table explicitly located at s3://... and credential-providers=s3-token. In both cases this returns with only fs.hadoop.enabled, so IRC can vend an S3 session credential that Trino still cannot consume. Please derive native filesystem enablement from credential-providers as well, or otherwise support per-table schemes, and cover no-warehouse/different-table-location cases with a MinIO STS end-to-end test.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergConnectorAdapter.java:
##########
@@ -20,42 +20,131 @@
import static java.util.Collections.emptyList;
+import com.google.common.collect.ImmutableMap;
import io.trino.spi.session.PropertyMetadata;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.gravitino.catalog.property.PropertyConverter;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
import org.apache.gravitino.credential.Credential;
+import org.apache.gravitino.trino.connector.GravitinoConfig;
import org.apache.gravitino.trino.connector.catalog.CatalogConnectorAdapter;
import org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadataAdapter;
import org.apache.gravitino.trino.connector.metadata.GravitinoCatalog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Transforming Apache Iceberg connector configuration and components into Apache Gravitino
* connector.
*/
public class IcebergConnectorAdapter implements CatalogConnectorAdapter {
+ private static final Logger LOG = LoggerFactory.getLogger(IcebergConnectorAdapter.class);
+
private static final String CONNECTOR_ICEBERG = "iceberg";
+ private static final String REST_CATALOG_BACKEND = "rest";
+ private static final String ICEBERG_PROVIDER = "lakehouse-iceberg";
+
+ /**
+ * Synthetic catalog property carrying the Iceberg REST server endpoint the coordinator discovered
+ * for this catalog's metalake. {@link GravitinoConfig}'s own discovered-endpoint map is populated
+ * only on the coordinator (the periodic discovery poll never runs on a worker), so it cannot be
+ * read directly when building a catalog's internal connector config: every node needs the same
+ * routing decision for the same catalog. Embedding the resolved endpoint into the catalog itself,
+ * at registration time, means it travels to every node through the {@code CREATE CATALOG}
+ * statement Trino replicates cluster-wide, the same way any other catalog property does.
+ */
+ static final String DISCOVERED_ICEBERG_REST_URI_PROPERTY = "__gravitino.iceberg.rest-uri";
+
private final IcebergPropertyMeta propertyMetadata;
- private final PropertyConverter catalogConverter;
+ private final IcebergCatalogPropertyConverter catalogConverter;
+ private final GravitinoConfig config;
/**
* Constructs a new IcebergConnectorAdapter. Initializes the property metadata and catalog
* converter for handling Iceberg-specific configurations.
+ *
+ * @param config the Gravitino connector configuration
*/
- public IcebergConnectorAdapter() {
+ public IcebergConnectorAdapter(GravitinoConfig config) {
this.propertyMetadata = new IcebergPropertyMeta();
this.catalogConverter = new IcebergCatalogPropertyConverter();
+ this.config = config;
}
@Override
public Map<String, String> buildInternalConnectorConfig(
GravitinoCatalog catalog, Credential[] credentials) throws Exception {
- Map<String, String> config =
+ // The catalog backend describes how Gravitino stores the metadata; it does not decide how
+ // Trino reaches the data. Whenever an Iceberg REST server endpoint is available for this
+ // catalog's metalake, the catalog is loaded through it, the only path that supports temporary
+ // credentials. A catalog that already has a REST backend keeps pointing at its own configured
+ // endpoint. If no endpoint is available, this falls back to translating catalog-backend as
+ // before — nothing to configure either way.
+ //
+ // The manual override is plain local config, so it is valid on every node as-is. The
+ // discovered endpoint is coordinator-only knowledge, so it is read from the catalog's own
+ // properties, where the coordinator embeds it at registration time (see
+ // embedDiscoveredIcebergRestUri), rather than from GravitinoConfig directly.
+ String restUri = config.getManualIcebergRestUri();
Review Comment:
The manual URI is global and wins for every catalog. In multi-metalake mode one IRC still serves exactly one metalake, so setting this override for metalake A also routes metalake B catalogs to A and causes REST lookup failures. Please scope the manual override to a metalake, provide per-metalake overrides, or reject this configuration in multi-metalake mode, with an A/B routing test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 merged PR #12555:
URL: https://github.com/apache/gravitino/pull/12555
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3892081003
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java:
##########
@@ -152,6 +246,99 @@ private Map<String, String> buildJDBCBackendProperties(Map<String, String> prope
return jdbcProperties;
}
+ private void warnOnReservedOverrides(GravitinoCatalog catalog, Map<String, String> config) {
+ for (String reserved : RESERVED_REST_PROPERTIES) {
+ if (config.containsKey(reserved)) {
+ LOG.info(
+ "Property '{}' set on catalog '{}' is ignored; the connector always derives it when "
+ + "routing through the Iceberg REST server.",
+ reserved,
+ catalog.getName());
+ }
+ }
+ }
+
+ /**
+ * Derives the Trino file system config from the catalog's warehouse location. Vended credentials
+ * are only consumed by Trino's native file systems, so the native implementation matching the
+ * warehouse scheme has to be enabled.
+ */
+ private Map<String, String> buildStorageProperties(Map<String, String> properties) {
+ Map<String, String> storageProperties = new HashMap<>();
+ // Always available as the fallback; where a native file system is also enabled below, that one
+ // takes precedence for its own scheme.
+ storageProperties.put(TRINO_FS_HADOOP_ENABLED, "true");
+
+ String warehouse = properties.get(IcebergConstants.WAREHOUSE);
Review Comment:
I think determining which filesystem to enable based on the URI scheme is enough.
We can add the integration test in the next PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3843681638
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogRegister.java:
##########
@@ -349,7 +191,7 @@ public void registerCatalog(String name, GravitinoCatalog catalog) {
}
String createCatalogCommand = generateCreateCatalogCommand(name, catalog);
executeSql(createCatalogCommand);
- LOG.info("Register catalog {} successfully: {}", name, createCatalogCommand);
+ LOG.info("Register catalog {} successfully: {}", name, redactSecrets(createCatalogCommand));
Review Comment:
This redacts only the successful log line. executeSql still builds its exception message with the raw SQL, and the upper load path logs that cause. Since the new REST OAuth credential is embedded in CREATE CATALOG, a failed registration can therefore expose credential/token/password values in logs. Please use the redacted command in every error/retry path as well, and verify how the submitted SQL is represented in Trino query history.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/IcebergRESTServiceOperations.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.GravitinoEnv;
+import org.apache.gravitino.auxiliary.AuxiliaryServiceManager;
+import org.apache.gravitino.dto.responses.IcebergRESTServiceResponse;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.server.web.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Reports the endpoint of the Gravitino Iceberg REST server, so that clients which already connect
+ * to this Gravitino server can discover it instead of requiring it to be configured separately.
+ */
+@Path("/system/iceberg-rest")
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public class IcebergRESTServiceOperations {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IcebergRESTServiceOperations.class);
+
+ // Matches gravitino.auxService.names / AuxiliaryServiceManager's registration key.
+ private static final String AUX_SERVICE_NAME = "iceberg-rest";
+ // Keys below are read from AuxiliaryServiceManager.getAuxServiceConfig, which already strips
+ // the gravitino.iceberg-rest. (or deprecated gravitino.auxService.iceberg-rest.) prefix, so
+ // they must NOT be re-prefixed here.
+ // The provider name used by the Iceberg REST server itself; see
+ // IcebergConstants.ICEBERG_REST_CATALOG_CONFIG_PROVIDER and DynamicIcebergConfigProvider. The
+ // server module cannot depend on iceberg-common/catalog-common, hence the literal here.
+ private static final String CATALOG_CONFIG_PROVIDER_KEY = "catalog-config-provider";
+ private static final String DYNAMIC_CATALOG_CONFIG_PROVIDER_NAME = "dynamic-config-provider";
+ // The post-strip key used by the Iceberg REST server itself; see
+ // IcebergConstants.GRAVITINO_METALAKE and DynamicIcebergConfigProvider.
+ private static final String SERVED_METALAKE_KEY = "gravitino-metalake";
+ private static final String HOST_KEY = "host";
+ private static final String HTTP_PORT_KEY = "httpPort";
+ private static final String HTTPS_PORT_KEY = "httpsPort";
+ private static final String ENABLE_HTTPS_KEY = "enableHttps";
+ // Match IcebergConfig.DEFAULT_ICEBERG_REST_SERVICE_HTTP_PORT/HTTPS_PORT: the server module
+ // cannot depend on iceberg-common, and JettyServerConfig's own defaults are the Gravitino
+ // server's (8090/8433), not the Iceberg REST server's — reading raw values with these
+ // defaults avoids silently reporting the wrong port when httpPort is not set explicitly.
+ private static final int DEFAULT_HTTP_PORT = 9001;
+ private static final int DEFAULT_HTTPS_PORT = 9433;
+ private static final String DEFAULT_HOST = "0.0.0.0";
+
+ @Context private HttpServletRequest httpRequest;
+
+ /**
+ * Reports the Iceberg REST server's endpoint for the requested metalake.
+ *
+ * @param metalake the metalake the caller intends to route through the Iceberg REST server; may
+ * be blank, in which case the endpoint is reported regardless of which metalake it serves
+ * @return a response whose {@code uri} is {@code null} when the Iceberg REST server is not
+ * running, or does not serve the requested metalake
+ */
+ @GET
+ @Timed(name = "iceberg-rest-service." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "iceberg-rest-service", absolute = true)
+ public Response getIcebergRestServiceUri(@QueryParam("metalake") String metalake) {
+ // The reported host can depend on the caller's own Host header (see resolveUri), so this
+ // response must never be cached and replayed to a different caller.
+ return Response.fromResponse(Utils.ok(new IcebergRESTServiceResponse(resolveUri(metalake))))
+ .header("Cache-Control", "no-store")
+ .build();
+ }
+
+ // Overridable so tests can inject a fixture without bootstrapping GravitinoEnv, matching
+ // HealthOperations's testing pattern.
+ AuxiliaryServiceManager getAuxServiceManager() {
+ return GravitinoEnv.getInstance().auxServiceManager();
+ }
+
+ // Resolved through AuxiliaryServiceManager.getAuxServiceConfig rather than reading
+ // gravitino.iceberg-rest.* directly, so the deprecated gravitino.auxService.iceberg-rest.*
+ // config form is honored too — the same precedence the Iceberg REST server itself sees.
+ Map<String, String> getIcebergRestServiceConfig() {
+ return AuxiliaryServiceManager.getAuxServiceConfig(
+ GravitinoEnv.getInstance().config(), AUX_SERVICE_NAME);
+ }
+
+ HttpServletRequest getHttpRequest() {
+ return httpRequest;
+ }
+
+ private String resolveUri(String metalake) {
+ if (!getAuxServiceManager().isAuxServiceRegistered(AUX_SERVICE_NAME)) {
+ return null;
+ }
+
+ Map<String, String> config = getIcebergRestServiceConfig();
+ String provider = config.getOrDefault(CATALOG_CONFIG_PROVIDER_KEY, "");
+ if (!DYNAMIC_CATALOG_CONFIG_PROVIDER_NAME.equals(provider)) {
+ // Only the dynamic catalog config provider maps Iceberg REST catalog names onto Gravitino
+ // catalogs; the default static provider serves statically-declared catalogs unrelated to
+ // Gravitino catalog names, so routing at it would 404 on every request.
+ LOG.debug(
+ "Iceberg REST service does not use the dynamic catalog config provider "
+ + "(catalog-config-provider={}); not reporting its endpoint for auto-discovery.",
+ provider);
+ return null;
+ }
+
+ String servedMetalake = config.getOrDefault(SERVED_METALAKE_KEY, "");
+ if (StringUtils.isNotBlank(metalake)
+ && StringUtils.isNotBlank(servedMetalake)
+ && !servedMetalake.equals(metalake)) {
+ // The Iceberg REST server serves exactly one metalake. Routing a different metalake's
+ // catalogs at it would 404 on every request, so report it as unavailable instead.
+ LOG.debug(
+ "Iceberg REST service serves metalake {}, not the requested metalake {}; not "
+ + "reporting its endpoint for auto-discovery.",
+ servedMetalake,
+ metalake);
+ return null;
+ }
+
+ String host = config.getOrDefault(HOST_KEY, DEFAULT_HOST);
+ if (isWildcardHost(host)) {
+ // The Iceberg REST server binds to all interfaces, so it has no single externally
+ // reachable address of its own. The caller already reached this Gravitino server at some
+ // resolvable host, so reuse it — this holds whenever both services share a host, which is
+ // the common case, and callers with a genuinely split topology can still set
+ // gravitino.iceberg.rest-uri manually.
+ host = getHttpRequest().getServerName();
+ }
+ boolean enableHttps = Boolean.parseBoolean(config.getOrDefault(ENABLE_HTTPS_KEY, "false"));
+ String scheme = enableHttps ? "https" : "http";
+ int port =
+ parsePort(
+ config,
+ enableHttps ? HTTPS_PORT_KEY : HTTP_PORT_KEY,
+ enableHttps ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT);
+ return String.format("%s://%s:%d/iceberg", scheme, host, port);
Review Comment:
String formatting does not bracket IPv6 literals. An explicit host or request server name of ::1 produces http://::1:9001/iceberg, which is not a valid URI; it must be http://[::1]:9001/iceberg. Please build this with a URI-aware utility and test both explicit IPv6 and wildcard-host fallback to IPv6.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3892070916
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergConnectorAdapter.java:
##########
@@ -20,42 +20,131 @@
import static java.util.Collections.emptyList;
+import com.google.common.collect.ImmutableMap;
import io.trino.spi.session.PropertyMetadata;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.gravitino.catalog.property.PropertyConverter;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
import org.apache.gravitino.credential.Credential;
+import org.apache.gravitino.trino.connector.GravitinoConfig;
import org.apache.gravitino.trino.connector.catalog.CatalogConnectorAdapter;
import org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadataAdapter;
import org.apache.gravitino.trino.connector.metadata.GravitinoCatalog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Transforming Apache Iceberg connector configuration and components into Apache Gravitino
* connector.
*/
public class IcebergConnectorAdapter implements CatalogConnectorAdapter {
+ private static final Logger LOG = LoggerFactory.getLogger(IcebergConnectorAdapter.class);
+
private static final String CONNECTOR_ICEBERG = "iceberg";
+ private static final String REST_CATALOG_BACKEND = "rest";
+ private static final String ICEBERG_PROVIDER = "lakehouse-iceberg";
+
+ /**
+ * Synthetic catalog property carrying the Iceberg REST server endpoint the coordinator discovered
+ * for this catalog's metalake. {@link GravitinoConfig}'s own discovered-endpoint map is populated
+ * only on the coordinator (the periodic discovery poll never runs on a worker), so it cannot be
+ * read directly when building a catalog's internal connector config: every node needs the same
+ * routing decision for the same catalog. Embedding the resolved endpoint into the catalog itself,
+ * at registration time, means it travels to every node through the {@code CREATE CATALOG}
+ * statement Trino replicates cluster-wide, the same way any other catalog property does.
+ */
+ static final String DISCOVERED_ICEBERG_REST_URI_PROPERTY = "__gravitino.iceberg.rest-uri";
+
private final IcebergPropertyMeta propertyMetadata;
- private final PropertyConverter catalogConverter;
+ private final IcebergCatalogPropertyConverter catalogConverter;
+ private final GravitinoConfig config;
/**
* Constructs a new IcebergConnectorAdapter. Initializes the property metadata and catalog
* converter for handling Iceberg-specific configurations.
+ *
+ * @param config the Gravitino connector configuration
*/
- public IcebergConnectorAdapter() {
+ public IcebergConnectorAdapter(GravitinoConfig config) {
this.propertyMetadata = new IcebergPropertyMeta();
this.catalogConverter = new IcebergCatalogPropertyConverter();
+ this.config = config;
}
@Override
public Map<String, String> buildInternalConnectorConfig(
GravitinoCatalog catalog, Credential[] credentials) throws Exception {
- Map<String, String> config =
+ // The catalog backend describes how Gravitino stores the metadata; it does not decide how
+ // Trino reaches the data. Whenever an Iceberg REST server endpoint is available for this
+ // catalog's metalake, the catalog is loaded through it, the only path that supports temporary
+ // credentials. A catalog that already has a REST backend keeps pointing at its own configured
+ // endpoint. If no endpoint is available, this falls back to translating catalog-backend as
+ // before — nothing to configure either way.
+ //
+ // The manual override is plain local config, so it is valid on every node as-is. The
+ // discovered endpoint is coordinator-only knowledge, so it is read from the catalog's own
+ // properties, where the coordinator embeds it at registration time (see
+ // embedDiscoveredIcebergRestUri), rather than from GravitinoConfig directly.
+ String restUri = config.getManualIcebergRestUri();
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3893604363
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java:
##########
@@ -152,6 +248,99 @@ private Map<String, String> buildJDBCBackendProperties(Map<String, String> prope
return jdbcProperties;
}
+ private void warnOnReservedOverrides(GravitinoCatalog catalog, Map<String, String> config) {
Review Comment:
Added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3892145522
##########
server/src/main/java/org/apache/gravitino/server/web/rest/IcebergRESTServiceOperations.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.GravitinoEnv;
+import org.apache.gravitino.auxiliary.AuxiliaryServiceManager;
+import org.apache.gravitino.dto.responses.IcebergRESTServiceResponse;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.server.web.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Reports the endpoint of the Gravitino Iceberg REST server, so that clients which already connect
+ * to this Gravitino server can discover it instead of requiring it to be configured separately.
+ */
+@Path("/system/iceberg-rest")
Review Comment:
Looked at reusing JettyServerConfig for this — its port defaults are the Gravitino server's own (8090/8433), not Iceberg REST's(9001/9433), and its intConf() throws on a malformed port instead of falling back to the default like we do now. Both are fixable but add complexity for little gain here, so I'll keep the current lightweight map-based parsing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3843680860
##########
server/src/main/java/org/apache/gravitino/server/web/rest/IcebergRESTServiceOperations.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.GravitinoEnv;
+import org.apache.gravitino.auxiliary.AuxiliaryServiceManager;
+import org.apache.gravitino.dto.responses.IcebergRESTServiceResponse;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.server.web.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Reports the endpoint of the Gravitino Iceberg REST server, so that clients which already connect
+ * to this Gravitino server can discover it instead of requiring it to be configured separately.
+ */
+@Path("/system/iceberg-rest")
Review Comment:
Could u reuse config operations interface? You can put Iceberg REST config into the config interfaces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3829502813
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java:
##########
@@ -152,6 +172,102 @@ private Map<String, String> buildJDBCBackendProperties(Map<String, String> prope
return jdbcProperties;
}
+ /**
+ * Builds the Trino Iceberg connector config that reaches this catalog through the Gravitino
+ * Iceberg REST server, regardless of the catalog backend Gravitino uses to store its metadata.
+ *
+ * <p>This is the only path on which credential vending works: the Iceberg REST protocol issues a
+ * fresh temporary credential per table access, while Trino's jdbc and hive_metastore Iceberg
+ * catalog types have nowhere to put the session token of an STS credential.
+ *
+ * @param catalog the Gravitino catalog to load
+ * @param gravitinoConfig the connector configuration holding the Iceberg REST server endpoint
+ * @return the Trino Iceberg connector config
+ */
+ public Map<String, String> buildIcebergRestProperties(
+ GravitinoCatalog catalog, GravitinoConfig gravitinoConfig) {
+ String restUri = gravitinoConfig.getIcebergRestUri();
+ if (StringUtils.isBlank(restUri)) {
+ throw new TrinoException(
+ GravitinoErrorCode.GRAVITINO_MISSING_CONFIG,
+ "Missing required config 'gravitino.iceberg.rest-uri'. Set it to the Gravitino Iceberg "
+ + "REST server endpoint, for example http://localhost:9001/iceberg, or set "
+ + "'gravitino.iceberg.rest-enabled=false' to load Iceberg catalogs through their "
+ + "catalog backend instead.");
+ }
+
+ Map<String, String> config = new HashMap<>();
+ // The order of put operations determines the priority of parameters.
+ config.putAll(buildStorageProperties(catalog.getProperties()));
+ config.put(TRINO_ICEBERG_REST_VENDED_CREDENTIALS, "true");
+ if (gravitinoConfig.isForwardUser()) {
+ config.put(TRINO_ICEBERG_REST_SESSION, "USER");
+ }
+ // The catalog's own trino.bypass properties override the defaults above, so that a Trino
+ // release renaming one of them can be worked around without a connector change.
+ config.putAll(super.gravitinoToEngineProperties(catalog.getProperties()));
+ // The Iceberg REST server endpoint and its authentication are cluster-level operational
+ // settings, so they take precedence over anything set on a single catalog.
+ config.putAll(gravitinoConfig.getIcebergRestCatalogConfig());
Review Comment:
The comment about “order of put operations” is misleading with a `HashMap` (iteration order is not guaranteed). What actually enforces priority here is overwrite semantics (later `put/putAll` overrides earlier values for the same keys). Update the comment to explicitly describe overwrite precedence, or switch to an insertion-ordered map (e.g., `LinkedHashMap`) if you want deterministic ordering for debugging/inspection.
##########
trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryITBase.java:
##########
@@ -46,6 +48,8 @@
public class TrinoQueryITBase {
private static final Logger LOG = LoggerFactory.getLogger(TrinoQueryITBase.class);
+ private static final String GRAVITINO_ICEBERG_REST_PREFIX = "gravitino.iceberg-rest.";
Review Comment:
This prefix constant is duplicated (also appears in `TrinoConnectorIT`). Consider centralizing it (e.g., in `BaseIT` or a shared test utility) to avoid drift if the aux-service config prefix ever changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#issuecomment-5369566154
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|67.58% **`+0.02%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|74.82%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|49.14%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|authorization-ranger|4.38%|:red_circle:|
|aws|42.04%|:green_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|9.92%|:red_circle:|
|catalog-fileset|79.77%|:green_circle:|
|catalog-glue|68.95%|:green_circle:|
|catalog-hive|82.96%|:green_circle:|
|catalog-jdbc-common|45.7%|:green_circle:|
|catalog-jdbc-doris|82.44%|:green_circle:|
|catalog-jdbc-mysql|79.33%|:green_circle:|
|catalog-jdbc-postgresql|83.39%|:green_circle:|
|catalog-jdbc-starrocks|79.16%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|59.18%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.86%|:green_circle:|
|catalog-lakehouse-paimon|84.23%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.58%|:green_circle:|
|common|52.39%|:green_circle:|
|core|83.57%|:green_circle:|
|filesystem-hadoop3|77.28%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|48.68%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|12.7%|:red_circle:|
|hive-metastore-common|53.4%|:green_circle:|
|iceberg-aliyun-bundle|0.0%|:red_circle:|
|iceberg-common|64.75%|:green_circle:|
|iceberg-rest-server|75.0%|:green_circle:|
|idp-basic|85.98%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|62.92%|:green_circle:|
|lance-common|31.63%|:red_circle:|
|lance-rest-server|63.47%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.24%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|87.57%|:green_circle:|
|server-common|79.57%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|45.89%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|42.99% **`+2.43%`**|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|trino-connector|[IcebergCatalogPropertyConverter.java](https://github.com/diqiu50/gravitino/blob/859ad4c82049c29099c90298f3f51085042d4b83/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java)|90.91%|:green_circle:|
||[IcebergConnectorAdapter.java](https://github.com/diqiu50/gravitino/blob/859ad4c82049c29099c90298f3f51085042d4b83/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergConnectorAdapter.java)|76.47%|:green_circle:|
||[GravitinoConfig.java](https://github.com/diqiu50/gravitino/blob/859ad4c82049c29099c90298f3f51085042d4b83/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoConfig.java)|74.24%|:green_circle:|
||[DefaultCatalogConnectorFactory.java](https://github.com/diqiu50/gravitino/blob/859ad4c82049c29099c90298f3f51085042d4b83/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/DefaultCatalogConnectorFactory.java)|0.0%|:red_circle:|
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12554] improvement(trino-connector): Route lakehouse-iceberg catalogs through the Iceberg REST server [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #12555:
URL: https://github.com/apache/gravitino/pull/12555#discussion_r3893171479
##########
docs/trino-connector/catalog-iceberg.md:
##########
@@ -20,6 +20,122 @@ To use Iceberg, you need:
- ORC
- Parquet (default)
+## How Trino Reaches the Catalog
+
+The Gravitino Trino connector loads every `lakehouse-iceberg` catalog through the Gravitino Iceberg
+REST server (IRC), regardless of the catalog's `catalog-backend`. `catalog-backend` describes how
+Gravitino stores the catalog's metadata; it does not decide how the query engine reaches the data.
+
+This is what makes [credential vending](../security/credential-vending.md) work. Trino only consumes
+vended credentials in its `rest` Iceberg catalog type — the `jdbc` and `hive_metastore` types have
+nowhere to put the session token of an STS temporary credential — so a catalog with
+`credential-providers=s3-token` produces no usable credential on those paths. Routing through the
+IRC means every table access gets a freshly issued temporary credential over the Iceberg REST
+protocol.
+
+The connector already connects to the Gravitino server (it is how catalogs are discovered in the
+first place), so it also asks that server whether it has an Iceberg REST server running as an
+[auxiliary service](../iceberg-rest-service.md) for the connector's metalake. By default, a
+non-REST `lakehouse-iceberg` catalog is not registered until an endpoint is discovered or configured
+explicitly. It is retried during every metadata refresh rather than silently falling back and
+disabling credential vending. To retain the behavior from older connector versions, set
+`gravitino.iceberg.rest-routing-enabled=false`; this skips discovery and translates the catalog's
+`catalog-backend` into the corresponding native Trino Iceberg configuration.
+
+Only the coordinator polls the Gravitino server, so the coordinator resolves the endpoint when a
+catalog is registered or refreshed and hands it to every node (coordinator and workers alike)
+as part of that catalog's own definition — the same way Trino replicates any other catalog property
+cluster-wide. A catalog that could not be registered before the IRC started is registered
+automatically after a later discovery poll succeeds; no Trino restart is required.
+
+Set `gravitino.iceberg.rest-uri` to override the discovered endpoint, and it is required — not just
+an override — for a standalone IRC (its own process, not the Gravitino server's auxiliary service):
+the Gravitino server has no way to know a standalone IRC exists, so discovery never finds one. See
+[Limitations](#limitations).
+
+```properties
+connector.name=gravitino
+gravitino.metalake=test
+gravitino.uri=http://gravitino-host:8090
+
+gravitino.iceberg.rest-uri=http://gravitino-host:9001/iceberg
+```
+
+The connector derives everything else from the catalog itself. The Gravitino catalog name is passed
+as both `iceberg.rest-catalog.warehouse` and `iceberg.rest-catalog.prefix` — the Iceberg client
+selects the catalog twice over, first as the query parameter of the `GET /v1/config` call that
+discovers it, then as the path segment of every request after that.
+
+The Trino native file system is derived from the catalog's `warehouse` scheme, because vended
+credentials are only consumed by Trino's native file systems:
+
+| Warehouse scheme | Derived properties |
+|:------------------------------------------|:------------------------------------------------------------------------------------------------------|
+| `s3://`, `s3a://`, `s3n://` | `fs.native-s3.enabled`, plus `s3.region`, `s3.endpoint` and `s3.path-style-access` where the catalog defines `s3-region`, `s3-endpoint` and `s3-path-style-access` |
Review Comment:
Format the table
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java:
##########
@@ -152,6 +248,99 @@ private Map<String, String> buildJDBCBackendProperties(Map<String, String> prope
return jdbcProperties;
}
+ private void warnOnReservedOverrides(GravitinoCatalog catalog, Map<String, String> config) {
Review Comment:
Can you add some comments about this method? I can't get the meaning from the method name.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogRegister.java:
##########
@@ -57,6 +60,18 @@ public class CatalogRegister {
private static final String SSL_VERIFICATION_NONE = "NONE";
private static final Set<String> SSL_VERIFICATION_MODES =
ImmutableSet.of(SSL_VERIFICATION_FULL, SSL_VERIFICATION_CA, SSL_VERIFICATION_NONE);
+ private static final Pattern SECRET_PROPERTY_PATTERN =
+ Pattern.compile(
+ "\"([^\"]*(?:credential|token|secret|password)[^\"]*)\"\\s*=\\s*'([^']*)'",
+ Pattern.CASE_INSENSITIVE);
+
+ // Matches "key":"value" style secret assignments inside the serialized GravitinoCatalog JSON
+ // that GRAVITINO_DYNAMIC_CONNECTOR_CATALOG_CONFIG carries (e.g. "jdbc-password":"..." or
+ // "s3-secret-key":"..."), which SECRET_PROPERTY_PATTERN's SQL-assignment shape does not match.
+ private static final Pattern SECRET_JSON_PROPERTY_PATTERN =
+ Pattern.compile(
+ "\"([^\"]*(?:credential|token|secret|password)[^\"]*)\"\\s*:\\s*\"([^\"]*)\"",
Review Comment:
Other words like `passcode` should also be considered. Is there a better way to detect it? It's not so elegant and will always suffer from conner cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org