Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(services/s3): remove default region us-east-1 for non-aws s3 #2812

Merged
merged 4 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/fuzz_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
OPENDAL_S3_ENDPOINT: "http://127.0.0.1:9000"
OPENDAL_S3_ACCESS_KEY_ID: minioadmin
OPENDAL_S3_SECRET_ACCESS_KEY: minioadmin
OPENDAL_S3_REGION: us-east-1

fuzz-test-fs:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/service_test_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ jobs:
OPENDAL_S3_ENDPOINT: "http://127.0.0.1:9000"
OPENDAL_S3_ACCESS_KEY_ID: minioadmin
OPENDAL_S3_SECRET_ACCESS_KEY: minioadmin
OPENDAL_S3_REGION: us-east-1

anonymous_minio_s3:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -178,6 +179,7 @@ jobs:
OPENDAL_S3_BUCKET: test
OPENDAL_S3_ENDPOINT: "http://127.0.0.1:9000"
OPENDAL_S3_ALLOW_ANONYMOUS: on
OPENDAL_S3_REGION: us-east-1

r2:
runs-on: ubuntu-latest
Expand Down
21 changes: 7 additions & 14 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl S3Builder {
///
/// If using a custom endpoint,
/// - If region is set, we will take user's input first.
/// - If not, the default `us-east-1` will be used.
/// - If not, we will try to load it from environment.
pub fn region(&mut self, region: &str) -> &mut Self {
if !region.is_empty() {
self.region = Some(region.to_string())
Expand Down Expand Up @@ -772,19 +772,12 @@ impl Builder for S3Builder {
cfg.region = Some(v);
}
if cfg.region.is_none() {
// AWS S3 requires region to be set.
if self.endpoint.is_none()
|| self.endpoint.as_deref() == Some("https://s3.amazonaws.com")
{
return Err(Error::new(ErrorKind::ConfigInvalid, "region is missing")
.with_operation("Builder::build")
.with_context("service", Scheme::S3));
}

// For other compatible services, if we don't know region
// after loading from builder and env, we can use `us-east-1`
// as default.
cfg.region = Some("us-east-1".to_string());
return Err(Error::new(
ErrorKind::ConfigInvalid,
"region is missing. Please find it by S3::detect_region() or set them in env.",
)
.with_operation("Builder::build")
.with_context("service", Scheme::S3));
}

let region = cfg.region.to_owned().unwrap();
Expand Down