mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
* fix(s3): emit x-amz-transition-default-minimum-object-size on lifecycle GET/PUT (#441) terraform-provider-aws v6.x added a stability wait that compares TransitionDefaultMinimumObjectSize between PUT input and GET output. The AWS SDK v2 reads that field only from the x-amz-transition-default-minimum-object-size response header, never from the XML body. Floci stored lifecycle XML verbatim and never set the header, so the SDK parsed it as null/empty, never matched the provider default (all_storage_classes_128K), and the wait timed out after 3 minutes. Persist the value on the Bucket model, read it from the PUT request header (defaulting to all_storage_classes_128K), and emit it on both PUT and GET responses. DELETE clears it for symmetry. Coverage: - REST Assured tests for default/custom/round-trip/delete-clears. - AWS Java SDK v2 round-trip in S3LifecycleSdkIntegrationTest, the level the existing #492 body-only fix did not exercise. Issue #441 was auto-closed by #492 without a real fix; reopens the underlying defect. * test(s3): move SDK lifecycle round-trip to compatibility-tests - Move S3LifecycleSdkIntegrationTest to compatibility-tests/sdk-test-java as S3LifecycleTest, adapted to use TestFixtures.s3Client() and AssertJ to match the existing compat suite. - Drop the test-scope software.amazon.awssdk:s3 dependency from the main pom.xml; the in-tree JUnit tests do not need an SDK client. - Addresses review feedback on PR #615.
This commit is contained in:
5 files changed
+238
-6
No files matched your search
@@ -171,8 +171,12 @@ public class S3Controller {
|
||||
return Response.ok().build();
|
||||
}
|
||||
if (hasQueryParam(uriInfo, "lifecycle")) {
|
||||
s3Service.putBucketLifecycle(bucket, new String(body, StandardCharsets.UTF_8));
|
||||
return Response.ok().build();
|
||||
String requestedSize = httpHeaders.getHeaderString("x-amz-transition-default-minimum-object-size");
|
||||
String storedSize = s3Service.putBucketLifecycle(bucket,
|
||||
new String(body, StandardCharsets.UTF_8), requestedSize);
|
||||
return Response.ok()
|
||||
.header("x-amz-transition-default-minimum-object-size", storedSize)
|
||||
.build();
|
||||
}
|
||||
if (hasQueryParam(uriInfo, "acl")) {
|
||||
s3Service.putBucketAcl(bucket, new String(body, StandardCharsets.UTF_8));
|
||||
@@ -310,7 +314,10 @@ public class S3Controller {
|
||||
return Response.ok(s3Service.getBucketCors(bucket)).build();
|
||||
}
|
||||
if (hasQueryParam(uriInfo, "lifecycle")) {
|
||||
return Response.ok(s3Service.getBucketLifecycle(bucket)).build();
|
||||
S3Service.LifecycleConfigurationResult lc = s3Service.getBucketLifecycle(bucket);
|
||||
return Response.ok(lc.xml())
|
||||
.header("x-amz-transition-default-minimum-object-size", lc.transitionDefaultMinimumObjectSize())
|
||||
.build();
|
||||
}
|
||||
if (hasQueryParam(uriInfo, "acl")) {
|
||||
return Response.ok(s3Service.getBucketAcl(bucket)).build();
|
||||
|
||||
@@ -1357,26 +1357,40 @@ public class S3Service {
|
||||
bucketStore.put(bucketName, bucket);
|
||||
}
|
||||
|
||||
public String getBucketLifecycle(String bucketName) {
|
||||
public static final String DEFAULT_TRANSITION_DEFAULT_MIN_OBJECT_SIZE = "all_storage_classes_128K";
|
||||
|
||||
public record LifecycleConfigurationResult(String xml, String transitionDefaultMinimumObjectSize) {}
|
||||
|
||||
public LifecycleConfigurationResult getBucketLifecycle(String bucketName) {
|
||||
Bucket bucket = bucketStore.get(bucketName)
|
||||
.orElseThrow(() -> new AwsException("NoSuchBucket", "The specified bucket does not exist.", 404));
|
||||
if (bucket.getLifecycleConfiguration() == null) {
|
||||
throw new AwsException("NoSuchLifecycleConfiguration", "The lifecycle configuration does not exist", 404);
|
||||
}
|
||||
return bucket.getLifecycleConfiguration();
|
||||
String size = bucket.getTransitionDefaultMinimumObjectSize();
|
||||
if (size == null) {
|
||||
size = DEFAULT_TRANSITION_DEFAULT_MIN_OBJECT_SIZE;
|
||||
}
|
||||
return new LifecycleConfigurationResult(bucket.getLifecycleConfiguration(), size);
|
||||
}
|
||||
|
||||
public void putBucketLifecycle(String bucketName, String lifecycle) {
|
||||
public String putBucketLifecycle(String bucketName, String lifecycle, String transitionDefaultMinimumObjectSize) {
|
||||
Bucket bucket = bucketStore.get(bucketName)
|
||||
.orElseThrow(() -> new AwsException("NoSuchBucket", "The specified bucket does not exist.", 404));
|
||||
bucket.setLifecycleConfiguration(lifecycle);
|
||||
String size = (transitionDefaultMinimumObjectSize == null || transitionDefaultMinimumObjectSize.isBlank())
|
||||
? DEFAULT_TRANSITION_DEFAULT_MIN_OBJECT_SIZE
|
||||
: transitionDefaultMinimumObjectSize;
|
||||
bucket.setTransitionDefaultMinimumObjectSize(size);
|
||||
bucketStore.put(bucketName, bucket);
|
||||
return size;
|
||||
}
|
||||
|
||||
public void deleteBucketLifecycle(String bucketName) {
|
||||
Bucket bucket = bucketStore.get(bucketName)
|
||||
.orElseThrow(() -> new AwsException("NoSuchBucket", "The specified bucket does not exist.", 404));
|
||||
bucket.setLifecycleConfiguration(null);
|
||||
bucket.setTransitionDefaultMinimumObjectSize(null);
|
||||
bucketStore.put(bucketName, bucket);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ public class Bucket {
|
||||
private String policy;
|
||||
private String corsConfiguration;
|
||||
private String lifecycleConfiguration;
|
||||
private String transitionDefaultMinimumObjectSize; // x-amz-transition-default-minimum-object-size header value
|
||||
private String acl; // XML representation or JSON stub
|
||||
private String encryptionConfiguration; // XML string
|
||||
private String publicAccessBlockConfiguration; // XML string
|
||||
@@ -73,6 +74,11 @@ public class Bucket {
|
||||
public String getLifecycleConfiguration() { return lifecycleConfiguration; }
|
||||
public void setLifecycleConfiguration(String lifecycleConfiguration) { this.lifecycleConfiguration = lifecycleConfiguration; }
|
||||
|
||||
public String getTransitionDefaultMinimumObjectSize() { return transitionDefaultMinimumObjectSize; }
|
||||
public void setTransitionDefaultMinimumObjectSize(String transitionDefaultMinimumObjectSize) {
|
||||
this.transitionDefaultMinimumObjectSize = transitionDefaultMinimumObjectSize;
|
||||
}
|
||||
|
||||
public String getAcl() { return acl; }
|
||||
public void setAcl(String acl) { this.acl = acl; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user