You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "sadanand48 (via GitHub)" <gi...@apache.org> on 2023/08/31 16:18:48 UTC
[GitHub] [ozone] sadanand48 opened a new pull request, #5239: HDDS-4838. Deleting at bucket root throws NPE.
sadanand48 opened a new pull request, #5239:
URL: https://github.com/apache/ozone/pull/5239
## What changes were proposed in this pull request?
In case of deleting the root, In `o3fs`, the path would be pointing to a bucket, If it is not a fully qualified path, it would just be relative to the root and the path would be = "/"
path ="/";
NPE is obtained while doing path.getParent() as "/" parent will be null.
```java
String qpath = this.fs.makeQualified(path).toString();
Path trashRoot = this.fs.getTrashRoot(path);
Path trashCurrent = new Path(trashRoot, CURRENT);
Path trashPath = this.makeTrashRelativePath(trashCurrent, path);
Path baseTrashPath = this.makeTrashRelativePath(trashCurrent, path.getParent());
```
The fix here would be would be to make getTrashRoot() return a qualified path which even is the same behaviour in HDFS. If that is fixed we would get a proper warning while deleting the root as the below condition will pass
```java
else if (trashRoot.getParent().toString().startsWith(qpath)) {
throw new IOException("Cannot move \"" + path + "\" to the trash, as it contains the trash");
}
```
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-4838
## How was this patch tested?
Unit tests
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ayushtkn commented on a diff in pull request #5239: HDDS-4838. Deleting at bucket root throws NPE.
Posted by "ayushtkn (via GitHub)" <gi...@apache.org>.
ayushtkn commented on code in PR #5239:
URL: https://github.com/apache/ozone/pull/5239#discussion_r1313832035
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
Assert.assertTrue(o3fs.exists(userTrashCurrent));
// Check under trash, the key should be present
Assert.assertTrue(o3fs.exists(trashPath));
+
+ // Try to delete root
+ Path root = new Path(OZONE_URI_DELIMITER);
+ try {
+ trash.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
Review Comment:
Does this work:
```
Assert.assertThrows(IOException.class, () -> trash.moveToTrash(root));
```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
Assert.assertTrue(o3fs.exists(userTrashCurrent));
// Check under trash, the key should be present
Assert.assertTrue(o3fs.exists(trashPath));
+
+ // Try to delete root
+ Path root = new Path(OZONE_URI_DELIMITER);
+ try {
+ trash.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
+ // Also try with TrashPolicyDefault
+ OzoneConfiguration conf2 = new OzoneConfiguration(cluster.getConf());
+ conf2.setClass("fs.trash.classname", TrashPolicyDefault.class,
+ TrashPolicy.class);
+ Trash trashPolicyDefault = new Trash(conf2);
+ try {
+ trashPolicyDefault.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
Review Comment:
```
Assert.assertThrows(IOException.class, () -> trashPolicyDefault.moveToTrash(root));
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] sadanand48 commented on a diff in pull request #5239: HDDS-4838. Deleting at bucket root throws NPE.
Posted by "sadanand48 (via GitHub)" <gi...@apache.org>.
sadanand48 commented on code in PR #5239:
URL: https://github.com/apache/ozone/pull/5239#discussion_r1314176835
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
Assert.assertTrue(o3fs.exists(userTrashCurrent));
// Check under trash, the key should be present
Assert.assertTrue(o3fs.exists(trashPath));
+
+ // Try to delete root
+ Path root = new Path(OZONE_URI_DELIMITER);
+ try {
+ trash.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
+ // Also try with TrashPolicyDefault
+ OzoneConfiguration conf2 = new OzoneConfiguration(cluster.getConf());
+ conf2.setClass("fs.trash.classname", TrashPolicyDefault.class,
+ TrashPolicy.class);
+ Trash trashPolicyDefault = new Trash(conf2);
+ try {
+ trashPolicyDefault.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
Review Comment:
Done.
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
Assert.assertTrue(o3fs.exists(userTrashCurrent));
// Check under trash, the key should be present
Assert.assertTrue(o3fs.exists(trashPath));
+
+ // Try to delete root
+ Path root = new Path(OZONE_URI_DELIMITER);
+ try {
+ trash.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
Review Comment:
Done.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] aryangupta1998 commented on pull request #5239: HDDS-4838. Deleting at bucket root throws NPE.
Posted by "aryangupta1998 (via GitHub)" <gi...@apache.org>.
aryangupta1998 commented on PR #5239:
URL: https://github.com/apache/ozone/pull/5239#issuecomment-1709705587
Thanks, @ayushtkn and @ashishkumar50 for the reviews.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] aryangupta1998 merged pull request #5239: HDDS-4838. Deleting at bucket root throws NPE.
Posted by "aryangupta1998 (via GitHub)" <gi...@apache.org>.
aryangupta1998 merged PR #5239:
URL: https://github.com/apache/ozone/pull/5239
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org