HDDS-16101. Extract bucket lifecycle operations into dedicated handler - #10969
Merged
chungen0126 merged 1 commit intoAug 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the S3 Gateway bucket request handling by extracting bucket lifecycle configuration (GET/PUT/DELETE ?lifecycle) logic out of BucketCrudHandler into a dedicated BucketLifecycleHandler, and wires it into the existing bucket handler chain.
Changes:
- Introduces
BucketLifecycleHandlerto handle?lifecyclesubresource operations. - Registers
BucketLifecycleHandlerinBucketEndpoint’s handler chain ahead ofBucketCrudHandler. - Removes lifecycle-specific logic and related imports from
BucketCrudHandler, leaving it responsible for plain bucket create/delete.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketLifecycleHandler.java | New handler implementing bucket lifecycle GET/PUT/DELETE behavior previously embedded in CRUD handler. |
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java | Adds the new lifecycle handler into the bucket operation handler chain. |
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketCrudHandler.java | Removes lifecycle subresource handling so CRUD only applies to non-subresource bucket operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+106
to
+127
| private void verifyBucketOwner(S3RequestContext context, String bucketName) throws OS3Exception { | ||
| HttpHeaders httpHeaders = getHeaders(); | ||
| if (httpHeaders == null) { | ||
| return; | ||
| } | ||
| String expectedBucketOwner = httpHeaders.getHeaderString(EXPECTED_BUCKET_OWNER_HEADER); | ||
| if (expectedBucketOwner == null || expectedBucketOwner.isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| String actualOwner = context.getVolume().getBucket(bucketName).getOwner(); | ||
| if (actualOwner != null && !actualOwner.equals(expectedBucketOwner)) { | ||
| LOG.debug("Bucket: {}, ExpectedBucketOwner: {}, ActualBucketOwner: {}", | ||
| bucketName, expectedBucketOwner, actualOwner); | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, bucketName); | ||
| } | ||
| } catch (Exception ex) { | ||
| LOG.error("Owner verification failed for bucket: {}", bucketName, ex); | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, bucketName); | ||
| } | ||
| } |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR extracts S3 bucket lifecycle GET, PUT, and DELETE operations from
BucketCrudHandlerinto a dedicatedBucketLifecycleHandler.The new handler is registered in the bucket operation handler chain before
BucketCrudHandler. Lifecycle-specific request handling, owner verification,error mapping, and configuration conversion are moved without changing their
behavior.
BucketCrudHandleris left responsible only for regular bucket creation anddeletion.
What is the link to the Apache Jira?
https://issues.apache.org/jira/browse/HDDS-16101
How was this patch tested?
ozone-s3gatewaymodule successfully.TestS3LifecycleConfigurationGetTestS3LifecycleConfigurationPutTestS3LifecycleConfigurationDelete