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

Implement copy_if_not_exist for AmazonS3 using DynamoDB (#4880) #4918

Merged
merged 12 commits into from
Dec 26, 2023
2 changes: 2 additions & 0 deletions .github/workflows/object_store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: test
AWS_ENDPOINT: http://localhost:4566
AWS_ALLOW_HTTP: true
AWS_COPY_IF_NOT_EXISTS: dynamo:test-table:2000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally wanted to use a much lower timeout, e.g. 100ms, but in CI this resulted in timeouts. Likely Github are significantly over-provisioning CPU on these instances, resulting in very poor predictability

HTTP_URL: "http://localhost:8080"
GOOGLE_BUCKET: test-bucket
GOOGLE_SERVICE_ACCOUNT: "/tmp/gcs.json"
Expand All @@ -136,6 +137,7 @@ jobs:
docker run -d -p 4566:4566 localstack/localstack:3.0.1
docker run -d -p 1338:1338 amazon/amazon-ec2-metadata-mock:v1.9.2 --imdsv2
aws --endpoint-url=http://localhost:4566 s3 mb s3://test-bucket
aws --endpoint-url=http://localhost:4566 dynamodb create-table --table-name test-table --key-schema AttributeName=key,KeyType=HASH --attribute-definitions AttributeName=key,AttributeType=S --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
- name: Configure Azurite (Azure emulation)
# the magical connection string is from
Expand Down
24 changes: 10 additions & 14 deletions object_store/src/aws/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,27 +844,23 @@ impl AmazonS3Builder {
)) as _
};

let endpoint: String;
let bucket_endpoint: String;

// If `endpoint` is provided then its assumed to be consistent with
// `virtual_hosted_style_request`. i.e. if `virtual_hosted_style_request` is true then
// `endpoint` should have bucket name included.
if self.virtual_hosted_style_request.get()? {
endpoint = self
.endpoint
.unwrap_or_else(|| format!("https://{bucket}.s3.{region}.amazonaws.com"));
bucket_endpoint = endpoint.clone();
let bucket_endpoint = if self.virtual_hosted_style_request.get()? {
self.endpoint
.clone()
.unwrap_or_else(|| format!("https://{bucket}.s3.{region}.amazonaws.com"))
} else {
endpoint = self
.endpoint
.unwrap_or_else(|| format!("https://s3.{region}.amazonaws.com"));
bucket_endpoint = format!("{endpoint}/{bucket}");
}
match &self.endpoint {
None => format!("https://s3.{region}.amazonaws.com/{bucket}"),
Some(endpoint) => format!("{endpoint}/{bucket}"),
}
};

let config = S3Config {
region,
endpoint,
endpoint: self.endpoint,
bucket,
bucket_endpoint,
credentials,
Expand Down
Loading
Loading