diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/S3Resource.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/S3Resource.java index 94520d3d1649be..4c21cdac6e9fba 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/S3Resource.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/S3Resource.java @@ -137,7 +137,7 @@ protected void setProperties(Map properties) throws DdlException || Boolean.parseBoolean(properties.get(S3_VALIDITY_CHECK)); LOG.debug("s3 info need check validity : {}", needCheck); if (needCheck) { - boolean available = pingS3(); + boolean available = pingS3(this.properties); if (!available) { throw new DdlException("S3 can't use, please check your properties"); } @@ -149,7 +149,7 @@ protected void setProperties(Map properties) throws DdlException checkOptionalProperty(S3_CONNECTION_TIMEOUT_MS, DEFAULT_S3_CONNECTION_TIMEOUT_MS); } - private boolean pingS3() { + private boolean pingS3(Map properties) { String bucket = "s3://" + properties.getOrDefault(S3_BUCKET, "") + "/"; Map propertiesPing = new HashMap<>(); propertiesPing.put("AWS_ACCESS_KEY", properties.getOrDefault(S3_ACCESS_KEY, "")); @@ -201,6 +201,33 @@ public void modifyProperties(Map properties) throws DdlException throw new DdlException("current not support modify property : " + any.get()); } } + + boolean needCheck = !this.properties.containsKey(S3_VALIDITY_CHECK) + || Boolean.parseBoolean(this.properties.get(S3_VALIDITY_CHECK)); + if (properties.containsKey(S3_VALIDITY_CHECK)) { + needCheck = Boolean.parseBoolean(properties.get(S3_VALIDITY_CHECK)); + } + LOG.debug("s3 info need check validity : {}", needCheck); + if (needCheck) { + Map s3Properties = new HashMap<>(); + s3Properties.put(S3_BUCKET, properties.containsKey(S3_BUCKET) ? properties.get(S3_BUCKET) : + this.properties.getOrDefault(S3_BUCKET, "")); + s3Properties.put(S3_ACCESS_KEY, properties.containsKey(S3_ACCESS_KEY) ? properties.get(S3_ACCESS_KEY) : + this.properties.getOrDefault(S3_ACCESS_KEY, "")); + s3Properties.put(S3_SECRET_KEY, properties.containsKey(S3_SECRET_KEY) ? properties.get(S3_SECRET_KEY) : + this.properties.getOrDefault(S3_SECRET_KEY, "")); + s3Properties.put(S3_ENDPOINT, properties.containsKey(S3_ENDPOINT) ? properties.get(S3_ENDPOINT) : + this.properties.getOrDefault(S3_ENDPOINT, "")); + s3Properties.put(S3_REGION, properties.containsKey(S3_REGION) ? properties.get(S3_REGION) : + this.properties.getOrDefault(S3_REGION, "")); + s3Properties.put(S3_ROOT_PATH, properties.containsKey(S3_ROOT_PATH) ? properties.get(S3_ROOT_PATH) : + this.properties.getOrDefault(S3_ROOT_PATH, "")); + boolean available = pingS3(s3Properties); + if (!available) { + throw new DdlException("S3 can't use, please check your properties"); + } + } + // modify properties writeLock(); for (Map.Entry kv : properties.entrySet()) {