[ 
https://issues.apache.org/jira/browse/HDFS-15539?focusedWorklogId=481795&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-481795
 ]

ASF GitHub Bot logged work on HDFS-15539:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Sep/20 23:51
            Start Date: 10/Sep/20 23:51
    Worklog Time Spent: 10m 
      Work Description: smengcl commented on a change in pull request #2258:
URL: https://github.com/apache/hadoop/pull/2258#discussion_r486694935



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
##########
@@ -2442,4 +2442,38 @@ public void testGetTrashRootOnEZInSnapshottableDir()
       }
     }
   }
+
+  @Test
+  public void testDisallowSnapshotShouldThrowWhenTrashRootExists()
+      throws IOException {
+    Configuration conf = getTestConfiguration();
+    MiniDFSCluster cluster =
+        new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+    try {
+      DistributedFileSystem dfs = cluster.getFileSystem();
+      Path testDir = new Path("/disallowss/test1/");
+      Path file0path = new Path(testDir, "file-0");
+      dfs.create(file0path);
+      dfs.allowSnapshot(testDir);
+      // Create trash root manually
+      Path testDirTrashRoot = new Path(testDir, FileSystem.TRASH_PREFIX);
+      dfs.mkdirs(testDirTrashRoot);
+      // Try disallowing snapshot, should throw
+      try {
+        dfs.disallowSnapshot(testDir);
+        fail("Should have thrown IOException when trash root exists inside "

Review comment:
       Thanks! I have updated accordingly.




----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 481795)
    Time Spent: 50m  (was: 40m)

> When disallowing snapshot on a dir, throw exception if its trash root is not 
> empty
> ----------------------------------------------------------------------------------
>
>                 Key: HDFS-15539
>                 URL: https://issues.apache.org/jira/browse/HDFS-15539
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: hdfs
>            Reporter: Siyao Meng
>            Assignee: Siyao Meng
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> When snapshot is disallowed on a dir, {{getTrashRoots()}} won't return the 
> trash root in that dir anymore (if any). The risk is the trash root will be 
> left there forever.
> We need to throw an exception there and prompt the user to clean up or rename 
> the trash root if it is not empty.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to