Skip to content

Commit 1e014e3

Browse files
branch-4.0: [opt](catalog) Improve error messages in connectivity tests by using root cause information #58184 (#58358)
Cherry-picked from #58184 Co-authored-by: zy-kkk <[email protected]>
1 parent 3fcfd66 commit 1e014e3

12 files changed

+116
-7
lines changed

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/AbstractS3CompatibleConnectivityTester.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,10 @@ public void testFeConnection() throws Exception {
6666
client.headBucket(b -> b.bucket(s3Uri.getBucket()));
6767
}
6868
}
69+
70+
@Override
71+
public String getErrorHint() {
72+
return "Please check S3 credentials (access_key and secret_key or IAM role), "
73+
+ "region, and bucket (warehouse location) access permissions";
74+
}
6975
}

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/CatalogConnectivityTestCoordinator.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.doris.datasource.connectivity;
1919

2020
import org.apache.doris.common.DdlException;
21+
import org.apache.doris.common.util.Util;
2122
import org.apache.doris.datasource.property.metastore.HiveGlueMetaStoreProperties;
2223
import org.apache.doris.datasource.property.metastore.HiveHMSProperties;
2324
import org.apache.doris.datasource.property.metastore.IcebergGlueMetaStoreProperties;
@@ -94,8 +95,10 @@ private void testMetadataService() throws DdlException {
9495
try {
9596
metaTester.testConnection();
9697
} catch (Exception e) {
97-
throw new DdlException(metaTester.getTestType() + " connectivity test failed: "
98-
+ e.getMessage());
98+
String hint = metaTester.getErrorHint();
99+
String errorMsg = metaTester.getTestType() + " connectivity test failed: " + hint
100+
+ " Root cause: " + Util.getRootCauseMessage(e);
101+
throw new DdlException(errorMsg);
99102
}
100103

101104
// Store warehouse location for later use
@@ -142,15 +145,20 @@ private void testObjectStorageForWarehouse(StorageProperties testObjectStoragePr
142145
try {
143146
tester.testFeConnection();
144147
} catch (Exception e) {
145-
throw new DdlException(tester.getTestType() + " connectivity test failed: " + e.getMessage());
148+
String hint = tester.getErrorHint();
149+
String errorMsg = tester.getTestType() + " connectivity test failed: " + hint
150+
+ " Root cause: " + Util.getRootCauseMessage(e);
151+
throw new DdlException(errorMsg);
146152
}
147153

148154
// Test BE connection
149155
try {
150156
tester.testBeConnection();
151157
} catch (Exception e) {
152-
throw new DdlException(tester.getTestType()
153-
+ " connectivity test failed (compute node): " + e.getMessage());
158+
String hint = tester.getErrorHint();
159+
String errorMsg = tester.getTestType() + " connectivity test failed (compute node): " + hint
160+
+ " Root cause: " + Util.getRootCauseMessage(e);
161+
throw new DdlException(errorMsg);
154162
}
155163
}
156164

@@ -240,14 +248,20 @@ private void testExplicitlyConfiguredHdfs() throws DdlException {
240248
try {
241249
tester.testFeConnection();
242250
} catch (Exception e) {
243-
throw new DdlException("HDFS connectivity test failed: " + e.getMessage());
251+
String hint = tester.getErrorHint();
252+
String errorMsg = "HDFS connectivity test failed: " + hint
253+
+ " Root cause: " + Util.getRootCauseMessage(e);
254+
throw new DdlException(errorMsg);
244255
}
245256

246257
// Test BE connection
247258
try {
248259
tester.testBeConnection();
249260
} catch (Exception e) {
250-
throw new DdlException("HDFS connectivity test failed (compute node): " + e.getMessage());
261+
String hint = tester.getErrorHint();
262+
String errorMsg = "HDFS connectivity test failed (compute node): " + hint
263+
+ " Root cause: " + Util.getRootCauseMessage(e);
264+
throw new DdlException(errorMsg);
251265
}
252266
}
253267

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/HdfsCompatibleConnectivityTester.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ public String getTestType() {
3737
return "HDFS";
3838
}
3939

40+
@Override
41+
public String getErrorHint() {
42+
return "Please check HDFS namenode connectivity (fs.defaultFS), user permissions, and "
43+
+ "Kerberos configuration if applicable";
44+
}
45+
4046
@Override
4147
public void testFeConnection() throws Exception {
4248
// TODO: Implement HDFS connectivity test in the future if needed

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/HiveGlueMetaStoreConnectivityTester.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public String getTestType() {
3434
return "Hive Glue";
3535
}
3636

37+
@Override
38+
public String getErrorHint() {
39+
return "Please check AWS Glue credentials (access_key and secret_key or IAM role), region, "
40+
+ "and endpoint";
41+
}
42+
3743
@Override
3844
public void testConnection() throws Exception {
3945
glueTester.testConnection();

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/HiveHMSConnectivityTester.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public String getTestType() {
3333
return "Hive HMS";
3434
}
3535

36+
@Override
37+
public String getErrorHint() {
38+
return "Please check Hive Metastore Server connectivity (hive metastore uris)";
39+
}
40+
3641
@Override
3742
public void testConnection() throws Exception {
3843
hmsTester.testConnection();

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/IcebergGlueMetaStoreConnectivityTester.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
import org.apache.doris.datasource.property.metastore.AWSGlueMetaStoreBaseProperties;
2121
import org.apache.doris.datasource.property.metastore.AbstractIcebergProperties;
2222

23+
import org.apache.commons.lang3.StringUtils;
24+
25+
import java.util.regex.Pattern;
26+
2327
public class IcebergGlueMetaStoreConnectivityTester extends AbstractIcebergConnectivityTester {
28+
private static final Pattern S3_LOCATION_PATTERN = Pattern.compile("^(s3|s3a)://.+");
2429
private final AWSGlueMetaStoreBaseConnectivityTester glueTester;
2530

2631
public IcebergGlueMetaStoreConnectivityTester(AbstractIcebergProperties properties,
@@ -34,8 +39,36 @@ public String getTestType() {
3439
return "Iceberg Glue";
3540
}
3641

42+
@Override
43+
public String getErrorHint() {
44+
return "Please check AWS Glue credentials (access_key and secret_key or IAM role), "
45+
+ "region, warehouse location, and endpoint";
46+
}
47+
3748
@Override
3849
public void testConnection() throws Exception {
3950
glueTester.testConnection();
4051
}
52+
53+
@Override
54+
public String getTestLocation() {
55+
String warehouse = properties.getWarehouse();
56+
if (StringUtils.isBlank(warehouse)) {
57+
return null;
58+
}
59+
60+
String location = validateS3Location(warehouse);
61+
if (location == null) {
62+
throw new IllegalArgumentException(
63+
"Iceberg Glue warehouse location must be in S3 format (s3:// or s3a://), but got: " + warehouse);
64+
}
65+
return location;
66+
}
67+
68+
private String validateS3Location(String location) {
69+
if (StringUtils.isNotBlank(location) && S3_LOCATION_PATTERN.matcher(location).matches()) {
70+
return location;
71+
}
72+
return null;
73+
}
4174
}

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/IcebergHMSConnectivityTester.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public String getTestType() {
3333
return "Iceberg HMS";
3434
}
3535

36+
@Override
37+
public String getErrorHint() {
38+
return "Please check Hive Metastore Server connectivity (hive metastore uris)";
39+
}
40+
3641
@Override
3742
public void testConnection() throws Exception {
3843
hmsTester.testConnection();

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/IcebergRestConnectivityTester.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public String getTestType() {
4343
return "Iceberg REST";
4444
}
4545

46+
@Override
47+
public String getErrorHint() {
48+
return "Please check Iceberg REST Catalog URI, authentication credentials (OAuth2 or SigV4), "
49+
+ "warehouse location, and endpoint connectivity";
50+
}
51+
4652
@Override
4753
public void testConnection() throws Exception {
4854
Map<String, String> restProps = ((IcebergRestProperties) properties).getIcebergRestCatalogProperties();

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/IcebergS3TablesMetaStoreConnectivityTester.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ protected IcebergS3TablesMetaStoreConnectivityTester(
2525
super(properties);
2626
}
2727

28+
@Override
29+
public String getErrorHint() {
30+
return "Please check S3 credentials (access_key and secret_key or IAM role), endpoint, region, "
31+
+ "and warehouse location";
32+
}
33+
2834
@Override
2935
public void testConnection() throws Exception {
3036
// TODO: Implement Iceberg S3 Tables connectivity test in the future if needed

fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/MetaConnectivityTester.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ default String getTestLocation() {
3434
default String getTestType() {
3535
return "Meta";
3636
}
37+
38+
/**
39+
* Returns error hint for this connectivity test.
40+
* Subclasses can override to provide specific hints for troubleshooting.
41+
*/
42+
default String getErrorHint() {
43+
return "";
44+
}
3745
}

0 commit comments

Comments
 (0)