Copilot commented on code in PR #10670:
URL: https://github.com/apache/ozone/pull/10670#discussion_r3556800670


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -562,14 +562,19 @@ public Response head(
       @PathParam(PATH) String keyPath) throws IOException, OS3Exception {
     long startNanos = Time.monotonicNowNanos();
     S3GAction s3GAction = S3GAction.HEAD_KEY;
+    final int partNumber = queryParams().getInt(QueryParams.PART_NUMBER, 0);
 
     OzoneKey key;
     try {
       if (S3Owner.hasBucketOwnershipVerificationConditions(getHeaders())) {
         OzoneBucket bucket = getVolume().getBucket(bucketName);
         S3Owner.verifyBucketOwnerCondition(getHeaders(), bucketName, 
bucket.getOwner());
       }
-      key = getClientProtocol().headS3Object(bucketName, keyPath);
+      // A partNumber is validated against the object's parts and yields the
+      // metadata of that part; an out-of-range part throws InvalidPart.
+      key = (partNumber != 0) ?
+          getClientProtocol().getS3KeyDetails(bucketName, keyPath, partNumber) 
:
+          getClientProtocol().headS3Object(bucketName, keyPath);

Review Comment:
   HEAD requests with partNumber currently call getS3KeyDetails(..., 
partNumber), which sends an OmKeyArgs without headOp=true. On the OM side, 
KeyManagerImpl.lookupKey only skips block-token generation / pipeline refresh 
when args.isHeadOp() is true, so HEAD(partNumber=...) will do extra work and 
can fail due to token/SCM refresh issues even though HEAD only needs metadata. 
Consider adding a partNumber-aware head API (eg 
headS3Object(bucket,key,partNumber)) or extending the existing client/OM 
request path to set headOp=true while still applying part-number 
filtering/validation.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to