HDDS-13737. S3 ETag JSON should be quoted#9248
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses ETag handling inconsistencies in the S3 gateway by ensuring ETags are properly quoted in responses and unquoted when stored or compared internally. The changes standardize the format of ETags across multipart upload operations.
- Adds
stripQuotesandwrapInQuotesutility methods for consistent ETag formatting - Updates multipart upload endpoints to wrap ETags in quotes for HTTP responses
- Modifies tests to strip quotes from ETags before comparisons and XML serialization
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ObjectEndpointStreaming.java | Wraps ETag in quotes for multipart upload response headers |
| ObjectEndpoint.java | Adds stripQuotes/wrapInQuotes utilities and applies proper ETag formatting in multipart operations |
| AbstractS3SDKV2Tests.java | Updates tests to strip quotes from ETags before comparison and XML construction |
| AbstractS3SDKV1Tests.java | Updates tests to strip quotes from ETags before XML construction |
| S3SDKTestUtils.java | Adds stripQuotes utility method for test code reuse |
| mpu_lib.robot | Strips quotes from ETag before MD5 comparison in Robot Framework tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| String raw = ozoneOutputStream.getMetadata().get(ETAG); | ||
| if (raw != null) { | ||
| ozoneOutputStream.getMetadata().put(ETAG, stripQuotes(raw)); | ||
| } |
There was a problem hiding this comment.
Inconsistent ETag handling: The stripQuotes logic is only applied in the 'else' branch (lines 1070-1073) but not in the 'if (range != null)' branch (lines 1049-1059). Both branches copy source key metadata using putAll(), which means both should handle potentially quoted ETags consistently.
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.conf.StorageUnit; | ||
| import org.apache.hadoop.ozone.OzoneConsts; | ||
| import org.apache.hadoop.ozone.audit.AuditLogger.PerformanceStringBuilder; |
There was a problem hiding this comment.
Duplicate import: PerformanceStringBuilder is imported both as a static import (line 30) and as a regular import (line 115). The regular import should be removed since the static import is sufficient and already used throughout the code.
| import org.apache.hadoop.ozone.audit.AuditLogger.PerformanceStringBuilder; |
| import org.apache.hadoop.ozone.s3.util.RangeHeader; | ||
| import org.apache.hadoop.ozone.s3.util.RangeHeaderParserUtil; | ||
| import org.apache.hadoop.ozone.s3.util.S3Consts; | ||
| import org.apache.hadoop.ozone.s3.util.S3Consts.CopyDirective; |
There was a problem hiding this comment.
Duplicate import: CopyDirective is imported both as a static import (line 50) and as a regular import (line 142). The regular import should be removed since the static import is sufficient.
| import org.apache.hadoop.ozone.s3.util.S3Consts.CopyDirective; |
| * @param input The input string. | ||
| * @return The string without leading and trailing quotes. | ||
| */ | ||
| public static String stripQuotes(String input) { |
There was a problem hiding this comment.
We don't need this helper method. There's one in ObjectEndpoint.
There was a problem hiding this comment.
Thanks @jojochuang !
I remove it as expected.
|
After applying this PR, the same Mint test no longer fails for ETag error. Though it failed later for an unsupported feature.
So yes, looks like this PR is functionally correct. As long as the duplicate method and code style issue is fixed, this PR is ready. |
ivandika3
left a comment
There was a problem hiding this comment.
@echonesis Thanks for the fix, left some comments.
...zone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/S3SDKTestUtils.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java
Outdated
Show resolved
Hide resolved
ivandika3
left a comment
There was a problem hiding this comment.
@echonesis Thanks for the update. LGTM +1.
|
Thanks @echonesis for the patch and @jojochuang for the review. |
What changes were proposed in this pull request?
This PR updates the output response during using
aws s3api complete-multipart-uploadfunction for Apache Ozone.When we want to execute multi-part uploading, three steps/functions are included:
We could refer to the doc and figure out the defined response of
upload-partshould be{ "ETag": "\"e868e0f4719e394144ef36531ee6824c\"" }What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-13737
How was this patch tested?