You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ri...@apache.org on 2023/04/19 04:35:47 UTC

[ozone] branch master updated: HDDS-8424: Preserve legacy bucket getKeyInfo behavior (#4576)

This is an automated email from the ASF dual-hosted git repository.

ritesh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new c2c393a8ac HDDS-8424: Preserve legacy bucket getKeyInfo behavior (#4576)
c2c393a8ac is described below

commit c2c393a8acc69dba5258af66ca901dae2c08b2c1
Author: Ritesh H Shukla <ke...@gmail.com>
AuthorDate: Tue Apr 18 21:35:42 2023 -0700

    HDDS-8424: Preserve legacy bucket getKeyInfo behavior (#4576)
---
 hadoop-ozone/dist/src/main/smoketest/s3/commonawslib.robot          | 5 +++++
 hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot            | 6 ++++++
 .../src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java    | 3 +++
 3 files changed, 14 insertions(+)

diff --git a/hadoop-ozone/dist/src/main/smoketest/s3/commonawslib.robot b/hadoop-ozone/dist/src/main/smoketest/s3/commonawslib.robot
index b9622fbcf3..86ac9d5ebe 100644
--- a/hadoop-ozone/dist/src/main/smoketest/s3/commonawslib.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/s3/commonawslib.robot
@@ -112,6 +112,11 @@ Create bucket with name
     ${result} =          Execute AWSS3APICli  create-bucket --bucket ${bucket}
                          Should contain              ${result}         Location
                          Should contain              ${result}         ${bucket}
+Create legacy bucket
+    ${postfix} =         Generate Ozone String
+    ${legacy_bucket} =   Set Variable               legacy-bucket-${postfix}
+    ${result} =          Execute and checkrc        ozone sh bucket create -l LEGACY s3v/${legacy_bucket}   0
+    [Return]             ${legacy_bucket}
 
 Setup s3 tests
     Return From Keyword if    ${OZONE_S3_TESTS_SET_UP}
diff --git a/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot b/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot
index 90d07ed942..1d63bed73d 100644
--- a/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot
@@ -40,6 +40,12 @@ Head object in non existing bucket
     ${result} =         Execute AWSS3APICli and checkrc    head-object --bucket ${BUCKET}-non-existent --key ${PREFIX}/headobject/key=value/f1   255
                         Should contain          ${result}    404
                         Should contain          ${result}    Not Found
+Head object where path is a directory
+    ${legacy-bucket} =  Create legacy bucket
+    ${result} =         Execute AWSS3APICli and checkrc    put-object --bucket ${legacy-bucket} --key ${PREFIX}/headobject/keyvalue/f1 --body /tmp/testfile   0
+    ${result} =         Execute AWSS3APICli and checkrc    head-object --bucket ${legacy-bucket} --key ${PREFIX}/headobject/keyvalue/   255
+                        Should contain          ${result}    404
+                        Should contain          ${result}    Not Found
 
 Head non existing key
     ${result} =         Execute AWSS3APICli and checkrc    head-object --bucket ${BUCKET} --key ${PREFIX}/non-existent   255
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
index c2929fefd3..75e7500429 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
@@ -405,6 +405,9 @@ public class KeyManagerImpl implements KeyManager {
         value = getOmKeyInfoFSO(volumeName, bucketName, keyName);
       } else {
         value = getOmKeyInfoDirectoryAware(volumeName, bucketName, keyName);
+        if (bucketLayout.isLegacy() && value != null && !value.isFile()) {
+          value = null; // Legacy buckets do not report key info for directories
+        }
       }
     } catch (IOException ex) {
       if (ex instanceof OMException) {


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