Skip to content
Open
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
6 changes: 6 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/s3/bucketlifecycle.robot
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ Delete bucket lifecycle configuration
Should Be Empty ${result}
${result} = Execute AWSS3APICli and checkrc get-bucket-lifecycle-configuration --bucket ${bucket} 255
Should contain ${result} NoSuchLifecycleConfiguration

Delete bucket lifecycle configuration when none exists
[tags] no-bucket-type
${bucket} = Create bucket
${result} = Execute AWSS3APICli delete-bucket-lifecycle --bucket ${bucket}
Should Be Empty ${result}
Original file line number Diff line number Diff line change
Expand Up @@ -2156,8 +2156,8 @@ public void testS3LifecycleConfigurationDelete() {

// Test delete lifecycle for a bucket, while doesn't have lifecycle
assertNull(s3Client.getBucketLifecycleConfiguration(bucketName));
assertThrows(AmazonServiceException.class,
() -> s3Client.deleteBucketLifecycleConfiguration(bucketName));
// Idempotent delete: no exception expected even without an existing config
s3Client.deleteBucketLifecycleConfiguration(bucketName);

// First create a lifecycle configuration
BucketLifecycleConfiguration configuration = new BucketLifecycleConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ protected void deleteLifecycleConfiguration(S3RequestContext context, String buc
try {
context.getVolume().getBucket(bucketName).deleteLifecycleConfiguration();
} catch (OMException ex) {
if (ex.getResult() == OMException.ResultCodes.LIFECYCLE_CONFIGURATION_NOT_FOUND) {
throw S3ErrorTable.newError(
S3ErrorTable.NO_SUCH_LIFECYCLE_CONFIGURATION, bucketName);
// DeleteBucketLifecycle is idempotent: deleting a missing config
// must still return 204, not 404 — same as normal key deletion.
if (ex.getResult() != OMException.ResultCodes.LIFECYCLE_CONFIGURATION_NOT_FOUND) {
throw S3ErrorTable.newError(bucketName, ex);
}
throw ex;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,10 @@ public void setup() throws Exception {
@Test
public void testDeleteNonExistentLifecycleConfiguration()
throws Exception {
try {
bucketEndpoint.delete("bucket1");
fail();
} catch (OS3Exception ex) {
assertEquals(HTTP_NOT_FOUND, ex.getHttpCode());
assertEquals(NO_SUCH_LIFECYCLE_CONFIGURATION.getCode(),
ex.getCode());
}
// DeleteBucketLifecycle is idempotent: deleting a non-existent
// configuration must succeed with 204, not fail with 404.
Response r = bucketEndpoint.delete("bucket1");
assertEquals(HTTP_NO_CONTENT, r.getStatus());
}

@Test
Expand Down
Loading