sadanand48 commented on code in PR #4405:
URL: https://github.com/apache/ozone/pull/4405#discussion_r1154067503
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java:
##########
@@ -720,6 +670,99 @@ public boolean delete(Path f, boolean recursive) throws
IOException {
return result;
}
+ private boolean deleteBucket(Path f, boolean recursive, OFSPath ofsPath)
+ throws IOException {
+ // check status of normal bucket
+ try {
+ getFileStatus(f);
+ } catch (FileNotFoundException ex) {
+ // remove orpahan link bucket directly
Review Comment:
typo: orphan
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -888,8 +889,14 @@ public List<FileStatusAdapter> listStatus(String pathStr,
boolean recursive,
String startKey = ofsStartPath.getKeyName();
try {
OzoneBucket bucket = getBucket(ofsPath, false);
- List<OzoneFileStatus> statuses = bucket
- .listStatus(keyName, recursive, startKey, numEntries);
+ List<OzoneFileStatus> statuses;
+ if (bucket.isSourcePathExist()) {
+ statuses = bucket
+ .listStatus(keyName, recursive, startKey, numEntries);
+ } else {
+ statuses = Collections.emptyList();
Review Comment:
better to add a log here to communicate to the user that source bucket
doesn’t exist
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientUtils.java:
##########
@@ -69,9 +71,21 @@ public static BucketLayout
resolveLinkBucketLayout(OzoneBucket bucket,
DETECTED_LOOP_IN_BUCKET_LINKS);
}
- OzoneBucket sourceBucket =
- objectStore.getVolume(bucket.getSourceVolume())
- .getBucket(bucket.getSourceBucket());
+ OzoneBucket sourceBucket;
+ try {
+ sourceBucket =
+ objectStore.getVolume(bucket.getSourceVolume())
+ .getBucket(bucket.getSourceBucket());
+ } catch (OMException ex) {
+ if (ex.getResult().equals(VOLUME_NOT_FOUND)
+ || ex.getResult().equals(BUCKET_NOT_FOUND)) {
+ // for orphan link bucket, return layout as link bucket
+ bucket.setSourcePathExist(false);
+ return bucket.getBucketLayout();
Review Comment:
Inform the user that we are returning the layout of link bucket as source
bucket doesn't exist.
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemWithLinks.java:
##########
@@ -225,11 +225,9 @@ public void testLoopInLinkBuckets() throws Exception {
try {
FileSystem.get(conf);
- Assert.fail("Should throw Exception due to loop in Link Buckets");
Review Comment:
Before this change, filesystem wouldn't get initialised for orphan buckets
so no operations could be performed for these buckets, Now that we are allowing
orphan buckets to be accessed via FS, it would require to handle all operations
like delete/rename/ls etc for such buckets , should we allow this or just
restrict FS access? To delete the orphan bucket we could use the `ozone sh
bucket delete `
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java:
##########
@@ -720,6 +670,99 @@ public boolean delete(Path f, boolean recursive) throws
IOException {
return result;
}
+ private boolean deleteBucket(Path f, boolean recursive, OFSPath ofsPath)
+ throws IOException {
+ // check status of normal bucket
+ try {
+ getFileStatus(f);
+ } catch (FileNotFoundException ex) {
+ // remove orpahan link bucket directly
+ if (isLinkBucket(f, ofsPath)) {
+ deleteBucketFromVolume(f, ofsPath);
+ return true;
+ }
+ LOG.warn("delete: Path does not exist: {}", f);
+ return false;
+ }
+
+ // remove link bucket directly
+ if (isLinkBucket(f, ofsPath)) {
+ deleteBucketFromVolume(f, ofsPath);
+ return true;
+ }
+
+ // delete inner content of bucket
+ boolean result = innerDelete(f, recursive);
+
+ // Handle delete bucket
+ deleteBucketFromVolume(f, ofsPath);
+ return result;
+ }
+
+ private boolean isLinkBucket(Path f, OFSPath ofsPath) {
+ try {
+ OzoneBucket bucket = adapterImpl.getBucket(ofsPath, false);
+ if (bucket.isLink()) {
+ return true;
+ }
+ } catch (Exception ex) {
+ return false;
Review Comment:
can log the exception in case of failure.
--
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]