You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "hevinhsu (via GitHub)" <gi...@apache.org> on 2025/07/18 08:36:09 UTC

[PR] HDDS-13393. Support Presigned HeadObject and HeadBucket [ozone]

hevinhsu opened a new pull request, #8826:
URL: https://github.com/apache/ozone/pull/8826

   ## What changes were proposed in this pull request?
   AWS SDK Java SDK V2 v2.31.66 adds the ability to presign HeadObject and HeadBucket, we can test for this whether this is supported and add the support if it's not supported yet.
   
   Please describe your PR in detail:
   S3G already support head bucket/object in current version, so I add an integration test follow [testPresignedUrlGet](https://github.com/apache/ozone/blob/master/hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java#L439) in ```AbstractS3SDKV2Tests```
   
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-13393
   
   ## How was this patch tested?
   https://github.com/hevinhsu/ozone/actions/runs/16364093333
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Test Presigned HeadObject and HeadBucket support [ozone]

Posted by "hevinhsu (via GitHub)" <gi...@apache.org>.
hevinhsu commented on code in PR #8826:
URL: https://github.com/apache/ozone/pull/8826#discussion_r2217062860


##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -507,6 +511,97 @@ public void testPresignedUrlGet() throws Exception {
     }
   }
 
+  @Test
+  public void testPresignedUrlHead() throws Exception {
+    final String bucketName = getBucketName();
+    final String keyName = getKeyName();
+    final String content = "bar";
+    s3Client.createBucket(b -> b.bucket(bucketName));
+
+    s3Client.putObject(b -> b
+            .bucket(bucketName)
+            .key(keyName),
+        RequestBody.fromString(content));
+
+    try (S3Presigner presigner = S3Presigner.builder()
+        // TODO: Find a way to retrieve the path style configuration from S3Client instead
+        .serviceConfiguration(S3Configuration.builder().pathStyleAccessEnabled(true).build())
+        .endpointOverride(s3Client.serviceClientConfiguration().endpointOverride().get())
+        .region(s3Client.serviceClientConfiguration().region())
+        .credentialsProvider(s3Client.serviceClientConfiguration().credentialsProvider()).build()) {
+
+      HeadObjectRequest objectRequest = HeadObjectRequest.builder()
+          .bucket(bucketName)
+          .key(keyName)
+          .build();
+
+      HeadObjectPresignRequest presignRequest = HeadObjectPresignRequest.builder()
+          .signatureDuration(Duration.ofMinutes(10))
+          .headObjectRequest(objectRequest)
+          .build();
+
+      PresignedHeadObjectRequest presignedRequest = presigner.presignHeadObject(presignRequest);
+
+      URL presignedUrl = presignedRequest.url();
+      HttpURLConnection connection = (HttpURLConnection) presignedUrl.openConnection();

Review Comment:
   @jojochuang Thanks for the review. The connection and bucketConnection are now explicitly closed. PTAL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Test Presigned HeadObject and HeadBucket support [ozone]

Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on PR #8826:
URL: https://github.com/apache/ozone/pull/8826#issuecomment-3091901099

   Thanks @hevinhsu for the patch and @jojochuang @chungen0126 for the reviews.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Test Presigned HeadObject and HeadBucket support [ozone]

Posted by "hevinhsu (via GitHub)" <gi...@apache.org>.
hevinhsu commented on PR #8826:
URL: https://github.com/apache/ozone/pull/8826#issuecomment-3091959759

   Thanks @ivandika3 @jojochuang @chungen0126 for the reviews.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Test Presigned HeadObject and HeadBucket support [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #8826:
URL: https://github.com/apache/ozone/pull/8826#discussion_r2216979886


##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -507,6 +511,97 @@ public void testPresignedUrlGet() throws Exception {
     }
   }
 
+  @Test
+  public void testPresignedUrlHead() throws Exception {
+    final String bucketName = getBucketName();
+    final String keyName = getKeyName();
+    final String content = "bar";
+    s3Client.createBucket(b -> b.bucket(bucketName));
+
+    s3Client.putObject(b -> b
+            .bucket(bucketName)
+            .key(keyName),
+        RequestBody.fromString(content));
+
+    try (S3Presigner presigner = S3Presigner.builder()
+        // TODO: Find a way to retrieve the path style configuration from S3Client instead
+        .serviceConfiguration(S3Configuration.builder().pathStyleAccessEnabled(true).build())
+        .endpointOverride(s3Client.serviceClientConfiguration().endpointOverride().get())
+        .region(s3Client.serviceClientConfiguration().region())
+        .credentialsProvider(s3Client.serviceClientConfiguration().credentialsProvider()).build()) {
+
+      HeadObjectRequest objectRequest = HeadObjectRequest.builder()
+          .bucket(bucketName)
+          .key(keyName)
+          .build();
+
+      HeadObjectPresignRequest presignRequest = HeadObjectPresignRequest.builder()
+          .signatureDuration(Duration.ofMinutes(10))
+          .headObjectRequest(objectRequest)
+          .build();
+
+      PresignedHeadObjectRequest presignedRequest = presigner.presignHeadObject(presignRequest);
+
+      URL presignedUrl = presignedRequest.url();
+      HttpURLConnection connection = (HttpURLConnection) presignedUrl.openConnection();

Review Comment:
   connection and bucketConnection objects should be closed explicitly at the end of test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Support Presigned HeadObject and HeadBucket [ozone]

Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on PR #8826:
URL: https://github.com/apache/ozone/pull/8826#issuecomment-3088616997

   @hevinhsu Thanks for the patch. I'll take a look soon.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Test Presigned HeadObject and HeadBucket support [ozone]

Posted by "hevinhsu (via GitHub)" <gi...@apache.org>.
hevinhsu commented on PR #8826:
URL: https://github.com/apache/ozone/pull/8826#issuecomment-3089820403

   @ivandika3 Thanks for the review. I've added a HEAD Bucket test as part of ```testPresignedUrlHead.``` 
   PTAL.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Test Presigned HeadObject and HeadBucket support [ozone]

Posted by "hevinhsu (via GitHub)" <gi...@apache.org>.
hevinhsu commented on PR #8826:
URL: https://github.com/apache/ozone/pull/8826#issuecomment-3091377823

   @chungen0126 Thanks for pointing this out. Yes, it's possible — since ```AbstractS3SDKV1Tests``` already has a ```testPresignedUrlGet```, I've added the test case there. 
   PTAL.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Support Presigned HeadObject and HeadBucket [ozone]

Posted by "hevinhsu (via GitHub)" <gi...@apache.org>.
hevinhsu commented on PR #8826:
URL: https://github.com/apache/ozone/pull/8826#issuecomment-3088509220

   Feel free to close this PR if the test is not needed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13393. Test Presigned HeadObject and HeadBucket support [ozone]

Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 merged PR #8826:
URL: https://github.com/apache/ozone/pull/8826


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org