bshashikant commented on a change in pull request #2472:
URL: https://github.com/apache/hadoop/pull/2472#discussion_r526035428
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/HdfsAdmin.java
##########
@@ -171,7 +174,15 @@ public void clearQuotaByStorageType(Path src, StorageType
type) throws IOExcepti
public void allowSnapshot(Path path) throws IOException {
dfs.allowSnapshot(path);
if (dfs.isSnapshotTrashRootEnabled()) {
- dfs.provisionSnapshotTrash(path, TRASH_PERMISSION);
+ try {
+ dfs.provisionSnapshotTrash(path, TRASH_PERMISSION);
+ } catch (FileAlreadyExistsException ex) {
+ // Don't throw on FileAlreadyExistsException since it is likely due to
+ // admin allowing snapshot on an EZ root.
+ LOG.warn(ex.getMessage());
Review comment:
I think there are 2 approaches instead of just ignoring the
FileAlreadyExists exception:
1) we can just validate whether the existing Trash path is a directory and
validate the permissions and not throw FileAlreadyExists exception itself in
DistributedFileSystem.java#provisionSnapshotTrash
2) If the trash path already exists with right permissions, we can check if
the path is an encryption zone as well and throw FileAlreadyExists exception
only if its not an encryption zone. Similar change will be required for making
an snapshottable dir an encryption zone.
I am ok with either of the above approaches. I think just ignoring the
exception here will not work in case. the existing path is not a directory or
has right permissions.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]