Skip to content

Commit f9f5d38

Browse files
branch-3.1: [improve](glue)Refine Glue region and endpoint initialization #57365 (#57479)
Cherry-picked from #57365 Co-authored-by: Calvin Kirs <[email protected]>
1 parent 85cf341 commit f9f5d38

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.doris.common.io.Writable;
3131
import org.apache.doris.common.util.PrintableMap;
3232
import org.apache.doris.common.util.TimeUtils;
33+
import org.apache.doris.datasource.property.storage.BrokerProperties;
3334
import org.apache.doris.datasource.property.storage.StorageProperties;
3435
import org.apache.doris.fs.FileSystemFactory;
3536
import org.apache.doris.fs.PersistentFileSystem;
@@ -211,14 +212,15 @@ public void gsonPostProcess() {
211212
StorageProperties storageProperties = StorageProperties.createPrimary(this.fileSystem.properties);
212213
this.fileSystem = FileSystemFactory.get(storageProperties);
213214
} catch (RuntimeException exception) {
214-
LOG.warn("Failed to create file system from properties, error msg {}",
215+
LOG.warn("File system initialization failed due to incompatible configuration parameters. "
216+
+ "The system has reverted to BrokerFileSystem as a fallback. "
217+
+ "However, the current configuration is not supported by this version and"
218+
+ " cannot be used as is. "
219+
+ "Please review the configuration and update it to match the supported parameter"
220+
+ " format. Root cause: {}",
215221
ExceptionUtils.getRootCause(exception), exception);
216-
throw new IllegalStateException(
217-
"Failed to initialize file system due to incompatible configuration with the current version. "
218-
+ "This may be caused by a change in property formats or deprecated settings. "
219-
+ "Please verify your configuration and ensure it matches the "
220-
+ "new version requirements. error msg: "
221-
+ ExceptionUtils.getRootCause(exception), exception);
222+
BrokerProperties brokerProperties = BrokerProperties.of(this.fileSystem.name, this.fileSystem.properties);
223+
this.fileSystem = FileSystemFactory.get(brokerProperties);
222224
}
223225
}
224226

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBaseProperties.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static AWSGlueMetaStoreBaseProperties of(Map<String, String> properties)
9595
private ParamRules buildRules() {
9696

9797
return new ParamRules().requireTogether(new String[]{glueAccessKey, glueSecretKey},
98-
"glue.access_key and glue.secret_key must be set together")
98+
"glue.access_key and glue.secret_key must be set together")
9999
.requireAtLeastOne(new String[]{glueAccessKey, glueIAMRole},
100100
"At least one of glue.access_key or glue.role_arn must be set")
101101
.requireAtLeastOne(new String[]{glueEndpoint, glueRegion},
@@ -104,14 +104,20 @@ private ParamRules buildRules() {
104104

105105
private void checkAndInit() {
106106
buildRules().validate();
107-
107+
if (StringUtils.isNotBlank(glueRegion) && StringUtils.isNotBlank(glueEndpoint)) {
108+
return;
109+
}
110+
if (StringUtils.isBlank(glueEndpoint) && StringUtils.isNotBlank(glueRegion)) {
111+
return;
112+
}
113+
// glue region is not set, try to extract from endpoint
108114
Matcher matcher = ENDPOINT_PATTERN.matcher(glueEndpoint.toLowerCase());
109-
if (!matcher.matches()) {
110-
throw new IllegalArgumentException("Invalid AWS Glue endpoint: " + glueEndpoint);
115+
if (matcher.matches()) {
116+
this.glueRegion = extractRegionFromEndpoint(matcher);
111117
}
112-
113118
if (StringUtils.isBlank(glueRegion)) {
114-
this.glueRegion = extractRegionFromEndpoint(matcher);
119+
//follow aws sdk default region
120+
glueRegion = "us-east-1";
115121
}
116122
}
117123

fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBasePropertiesTest.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ void testValidPropertiesWithRegionFromEndpoint() {
4242
Assertions.assertEquals("us-east-1", glueProps.glueRegion);
4343
}
4444

45+
@Test
46+
void testValidPropertiesWithRegion() {
47+
Map<String, String> props = baseValidProps();
48+
props.put("glue.region", "us-east-1");
49+
props.put("glue.endpoint", "https://glue.us-east-1.amazonaws.com.cn");
50+
AWSGlueMetaStoreBaseProperties glueProps = AWSGlueMetaStoreBaseProperties.of(props);
51+
Assertions.assertTrue("https://glue.us-east-1.amazonaws.com.cn".equals(glueProps.glueEndpoint));
52+
Assertions.assertEquals("us-east-1", glueProps.glueRegion);
53+
props.remove("glue.region");
54+
glueProps = AWSGlueMetaStoreBaseProperties.of(props);
55+
Assertions.assertTrue("https://glue.us-east-1.amazonaws.com.cn".equals(glueProps.glueEndpoint));
56+
Assertions.assertEquals("us-east-1", glueProps.glueRegion);
57+
}
58+
4559
@Test
4660
void testValidPropertiesWithExplicitRegion() {
4761
Map<String, String> props = baseValidProps();
@@ -86,27 +100,18 @@ void testMissingEndpointThrows() {
86100
}
87101

88102
@Test
89-
void testInvalidEndpointThrows() {
103+
void testInvalidEndpoint() {
90104
Map<String, String> props = baseValidProps();
91105
props.put("glue.endpoint", "http://invalid-endpoint.com");
92-
93-
IllegalArgumentException ex = Assertions.assertThrows(
94-
IllegalArgumentException.class,
95-
() -> AWSGlueMetaStoreBaseProperties.of(props)
96-
);
97-
Assertions.assertTrue(ex.getMessage().contains("Invalid AWS Glue endpoint"));
106+
Assertions.assertDoesNotThrow(() -> AWSGlueMetaStoreBaseProperties.of(props));
98107
}
99108

100109
@Test
101110
void testExtractRegionFailsWhenPatternMatchesButNoRegion() {
102111
Map<String, String> props = baseValidProps();
103112
props.put("glue.endpoint", "glue..amazonaws.com"); // malformed
104-
105-
IllegalArgumentException ex = Assertions.assertThrows(
106-
IllegalArgumentException.class,
107-
() -> AWSGlueMetaStoreBaseProperties.of(props)
113+
Assertions.assertDoesNotThrow(() -> AWSGlueMetaStoreBaseProperties.of(props)
108114
);
109-
Assertions.assertTrue(ex.getMessage().contains("Invalid AWS Glue endpoint"));
110115
}
111116

112117
@Test

0 commit comments

Comments
 (0)