HDDS-15940. Handle unexpected OMExceptions in S3 putBucketLifecycleConfiguration#10848
Open
priyeshkaratha wants to merge 1 commit into
Open
HDDS-15940. Handle unexpected OMExceptions in S3 putBucketLifecycleConfiguration#10848priyeshkaratha wants to merge 1 commit into
priyeshkaratha wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes S3 Gateway bucket lifecycle PUT handling so unexpected OMException result codes are no longer swallowed and incorrectly returned as HTTP 200; instead they’re consistently translated into the appropriate S3 error response via S3ErrorTable.
Changes:
- Update
BucketCrudHandler.putBucketLifecycleConfiguration()to translate allOMExceptions usingS3ErrorTable.newError(bucketName, ex)rather than selectively rethrowing only a subset. - Add unit tests to ensure
QUOTA_EXCEEDEDmaps to HTTP 403 and unexpected/internal OM failures map to HTTP 500 (instead of returning a false success).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketCrudHandler.java | Ensures all OM failures during lifecycle config PUT are surfaced as proper S3 errors (no false HTTP 200). |
| hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestS3LifecycleConfigurationPut.java | Adds regression tests verifying non-explicitly handled OM errors are propagated as OS3Exception with correct HTTP/status codes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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?
BucketCrudHandler.putBucketLifecycleConfiguration()was catching OMException, but it only re-threw the exception forACCESS_DENIEDandINVALID_REQUEST. If any other error occurred such asQUOTA_EXCEEDED,NOT_SUPPORTED_OPERATION, or an unexpected internal OM error, then the exception was swallowed. The method then returned Response.ok().build(), causing the client to receive an incorrect HTTP 200 success response even though the operation had actually failed.Other S3 gateway handlers don't behave this way. They simply convert every OMException into the appropriate S3 error by calling
This change makes BucketCrudHandler follow the same pattern. S3ErrorTable.newError(bucketName, ex) translates the OM error into the correct S3 response. For example,
QUOTA_EXCEEDEDbecomes a 403 response, while unexpected errors become InternalError (HTTP 500).ACCESS_DENIEDandINVALID_REQUESTcontinue to behave exactly as before, but now the original exception is also preserved as the cause, making audit logs and stack traces more useful and consistent with the improvements from HDDS-15000.What is the link to the Apache JIRA
HDDS-15940
How was this patch tested?
Tested using added test cases and existing unit test cases.