diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java index 780b64a9355c..2403719ab79d 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java @@ -35,6 +35,7 @@ import org.apache.hadoop.ozone.MiniOzoneCluster; import org.apache.hadoop.ozone.OFSPath; import org.apache.hadoop.ozone.OzoneAcl; +import org.apache.hadoop.ozone.OzoneConfigKeys; import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.TestDataUtil; import org.apache.hadoop.ozone.client.ObjectStore; @@ -108,16 +109,19 @@ public class TestRootedOzoneFileSystem { @Parameterized.Parameters public static Collection data() { return Arrays.asList( - new Object[]{true, true}, - new Object[]{true, false}, - new Object[]{false, true}, - new Object[]{false, false}); + new Object[]{true, true, true}, + new Object[]{true, true, false}, + new Object[]{true, false, false}, + new Object[]{false, true, false}, + new Object[]{false, false, false} + ); } public TestRootedOzoneFileSystem(boolean setDefaultFs, - boolean enableOMRatis) { + boolean enableOMRatis, boolean isAclEnabled) { enabledFileSystemPaths = setDefaultFs; omRatisEnabled = enableOMRatis; + enableAcl = isAclEnabled; } public static FileSystem getFs() { @@ -134,6 +138,7 @@ public static Path getBucketPath() { private static boolean enabledFileSystemPaths; private static boolean omRatisEnabled; private static boolean isBucketFSOptimized = false; + private static boolean enableAcl; private static OzoneConfiguration conf; private static MiniOzoneCluster cluster = null; @@ -165,6 +170,7 @@ public static void init() throws Exception { conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, enabledFileSystemPaths); } + conf.setBoolean(OzoneConfigKeys.OZONE_ACL_ENABLED, enableAcl); cluster = MiniOzoneCluster.newBuilder(conf) .setNumDatanodes(3) .build(); diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithFSO.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithFSO.java index 686339397e01..14d667ba5ba8 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithFSO.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithFSO.java @@ -45,13 +45,14 @@ public class TestRootedOzoneFileSystemWithFSO @Parameterized.Parameters public static Collection data() { return Arrays.asList( - new Object[]{true, true}, - new Object[]{true, false}); + new Object[]{true, true, false}, + new Object[]{true, false, false} + ); } public TestRootedOzoneFileSystemWithFSO(boolean setDefaultFs, - boolean enableOMRatis) throws Exception { - super(setDefaultFs, enableOMRatis); + boolean enableOMRatis, boolean enableAcl) { + super(setDefaultFs, enableOMRatis, enableAcl); } @BeforeClass diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java index f25dd45f31ec..4b88c51a29f9 100644 --- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java +++ b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java @@ -223,31 +223,23 @@ private OzoneBucket getBucket(String volumeStr, String bucketStr, try { bucket = proxy.getBucketDetails(volumeStr, bucketStr); } catch (OMException ex) { - // Note: always create bucket if volumeStr matches "tmp" so -put works if (createIfNotExist) { - // Note: getBucketDetails always throws BUCKET_NOT_FOUND, even if - // the volume doesn't exist. - if (ex.getResult().equals(BUCKET_NOT_FOUND)) { - OzoneVolume volume; + // getBucketDetails can throw VOLUME_NOT_FOUND when the parent volume + // doesn't exist and ACL is enabled; it can only throw BUCKET_NOT_FOUND + // when ACL is disabled. Both exceptions need to be handled. + switch (ex.getResult()) { + case VOLUME_NOT_FOUND: + case BUCKET_NOT_FOUND: try { - volume = proxy.getVolumeDetails(volumeStr); - } catch (OMException getVolEx) { - if (getVolEx.getResult().equals(VOLUME_NOT_FOUND)) { - // Volume doesn't exist. Create it - try { - objectStore.createVolume(volumeStr); - } catch (OMException newVolEx) { - // Ignore the case where another client created the volume - if (!newVolEx.getResult().equals(VOLUME_ALREADY_EXISTS)) { - throw newVolEx; - } - } - } else { - throw getVolEx; + objectStore.createVolume(volumeStr); + } catch (OMException newVolEx) { + // Ignore the case where another client created the volume + if (!newVolEx.getResult().equals(VOLUME_ALREADY_EXISTS)) { + throw newVolEx; } - // Try get volume again - volume = proxy.getVolumeDetails(volumeStr); } + + OzoneVolume volume = proxy.getVolumeDetails(volumeStr); // Create the bucket try { volume.createBucket(bucketStr); @@ -257,6 +249,10 @@ private OzoneBucket getBucket(String volumeStr, String bucketStr, throw newBucEx; } } + break; + default: + // Throw unhandled exception + throw ex; } // Try get bucket again bucket = proxy.getBucketDetails(volumeStr, bucketStr);