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/06/05 08:20:31 UTC
[PR] [#9517] fix(hive-catalog): Pre-resolve metastore URI hostnames to avoid Docker FQDN issue [gravitino]
diqiu50 opened a new pull request, #11455:
URL: https://github.com/apache/gravitino/pull/11455
### What changes were proposed in this pull request?
Pre-resolve hostnames in `hive.metastore.uris` to IP before passing to the Hive MetaStore client.
### Why are the changes needed?
Fixes #9517. Hive's `resolveUris()` calls `getCanonicalHostName()` on the configured host, which
in Docker Compose returns FQDNs containing underscores (e.g. `host.network_default`).
`java.net.URI` rejects underscores, causing `URISyntaxException`. Pre-resolving to IP avoids this.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Added unit tests in `TestUtil`.
--
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] [#9517] fix(hive-catalog): Pre-resolve metastore URI hostnames to avoid Docker FQDN issue [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11455:
URL: https://github.com/apache/gravitino/pull/11455#discussion_r3361413026
##########
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/Util.java:
##########
@@ -41,8 +50,38 @@ public static void updateConfigurationFromProperties(
}
properties.forEach((k, v) -> config.set(k.toString(), v.toString()));
+ resolveMetastoreUriHosts(config);
} catch (Exception e) {
throw new RuntimeException("Failed to create configuration", e);
}
}
+
+ // Pre-resolve to IP so Hive's resolveUris() doesn't receive Docker FQDNs with underscores.
+ private static void resolveMetastoreUriHosts(Configuration config) {
+ String urisValue = config.get(HIVE_METASTORE_URIS);
+ if (StringUtils.isBlank(urisValue)) {
+ return;
+ }
+ String resolved =
+ Arrays.stream(urisValue.split(","))
+ .map(uri -> resolveUriHost(uri.trim()))
+ .collect(Collectors.joining(","));
+ config.set(HIVE_METASTORE_URIS, resolved);
+ }
+
+ private static String resolveUriHost(String uriStr) {
+ try {
+ URI uri = new URI(uriStr);
+ String host = uri.getHost();
+ if (StringUtils.isBlank(host)) {
+ return uriStr;
+ }
+ String ip = InetAddress.getByName(host).getHostAddress();
+ return new URI(uri.getScheme(), null, ip, uri.getPort(), uri.getPath(), null, null)
+ .toString();
Review Comment:
resolveUriHost() rebuilds the URI but drops user-info, query, and fragment (passing nulls), so any metastore URI containing those components would be silently altered. Since the intent is only to replace the host, preserve all URI components when reconstructing the URI.
##########
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/Util.java:
##########
@@ -18,14 +18,23 @@
*/
package org.apache.gravitino.hive.client;
+import java.net.InetAddress;
+import java.net.URI;
+import java.util.Arrays;
import java.util.Properties;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Util {
+ private static final Logger LOG = LoggerFactory.getLogger(Util.class);
+
public static final String HIVE_CONFIG_RESOURCES = "hive.config.resources";
+ private static final String HIVE_METASTORE_URIS = "hive.metastore.uris";
Review Comment:
Util duplicates the Hive metastore URI key string even though the codebase already defines HiveConstants.HIVE_METASTORE_URIS (and this module already uses it in HiveClientFactory). Reusing the shared constant avoids drift if the key ever changes and keeps the code consistent.
--
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] [#9517] fix(hive-catalog): Pre-resolve metastore URI hostnames to avoid Docker FQDN issue [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #11455:
URL: https://github.com/apache/gravitino/pull/11455
--
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] [#9517] fix(hive-catalog): Pre-resolve metastore URI hostnames to avoid Docker FQDN issue [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11455:
URL: https://github.com/apache/gravitino/pull/11455#issuecomment-4630384306
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|66.93%|:green_circle:|
|:-|:-|:-:|
|Files changed|66.67%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|46.8%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|3.66%|:red_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|10.04%|:red_circle:|
|catalog-fileset|80.35%|:green_circle:|
|catalog-glue|66.67%|:green_circle:|
|catalog-hive|79.35%|:green_circle:|
|catalog-jdbc-clickhouse|80.02%|:green_circle:|
|catalog-jdbc-common|45.31%|:green_circle:|
|catalog-jdbc-doris|80.28%|:green_circle:|
|catalog-jdbc-hologres|54.03%|:green_circle:|
|catalog-jdbc-mysql|79.23%|:green_circle:|
|catalog-jdbc-oceanbase|78.38%|:green_circle:|
|catalog-jdbc-postgresql|82.29%|:green_circle:|
|catalog-jdbc-starrocks|78.51%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|44.89%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.66%|:green_circle:|
|catalog-lakehouse-paimon|79.29%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.51%|:green_circle:|
|client-java|77.91%|:green_circle:|
|common|50.17%|:green_circle:|
|core|82.49%|:green_circle:|
|filesystem-hadoop3|76.97%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|46.09%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-common|10.39%|:red_circle:|
|hive-metastore-common|53.75% **`+0.25%`**|:green_circle:|
|iceberg-common|56.54%|:green_circle:|
|iceberg-rest-server|73.42%|:green_circle:|
|idp-basic|85.99%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|66.17%|:green_circle:|
|lance-common|20.83%|:red_circle:|
|lance-rest-server|60.27%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|82.95%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|85.73%|:green_circle:|
|server-common|73.28%|:green_circle:|
|spark|29.85%|:red_circle:|
|spark-common|41.01%|:green_circle:|
|trino-connector|39.97%|:red_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|hive-metastore-common|[Util.java](https://github.com/diqiu50/gravitino/blob/0bc61cc08ab91ed2b19cfc935c3006de18dfc30c/catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/Util.java)|66.67%|:green_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