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

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

                Author: ASF GitHub Bot
            Created on: 06/Nov/20 03:16
            Start Date: 06/Nov/20 03:16
    Worklog Time Spent: 10m 
      Work Description: ferhui commented on a change in pull request #2437:
URL: https://github.com/apache/hadoop/pull/2437#discussion_r518500077



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLoggerWithCommands.java
##########
@@ -1205,6 +1205,18 @@ public void testGetDatanodeStorageReport() throws 
Exception {
     }
   }
 
+  @Test
+  public void testDeleteRoot() throws Exception {
+    Path srcDir = new Path("/");
+    fileSys = DFSTestUtil.getFileSystemAs(user1, conf);
+    boolean result = fileSys.delete(srcDir, true);
+    fileSys.close();
+    assertTrue(result == false);

Review comment:
       As CI reports, it could be more simple here, assertFalse(result)?




----------------------------------------------------------------
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: 508345)
    Time Spent: 2h 50m  (was: 2h 40m)

> Audit log record the unexpected allowed result when delete called
> -----------------------------------------------------------------
>
>                 Key: HDFS-15667
>                 URL: https://issues.apache.org/jira/browse/HDFS-15667
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs
>    Affects Versions: 3.2.1, 3.4.0
>            Reporter: Baolong Mao
>            Assignee: Baolong Mao
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: screenshot-1.png, screenshot-2.png
>
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> I met this issue if rm root directory, for remove non-root and non-empty 
> directory, toRemovedBlocks isn't null, its toDeleteList size is 0.
>  !screenshot-1.png! 
> when will return null?
> Through this screenshot, we can find that if fileRemoved = -1, then 
> toRemovedBlocks = null
>  !screenshot-2.png! 
> And when deleteAllowed(iip) return false, fileRemoved can be -1,
> {code:java}
>  private static boolean deleteAllowed(final INodesInPath iip) {
>     if (iip.length() < 1 || iip.getLastINode() == null) {
>       if (NameNode.stateChangeLog.isDebugEnabled()) {
>         NameNode.stateChangeLog.debug(
>             "DIR* FSDirectory.unprotectedDelete: failed to remove "
>                 + iip.getPath() + " because it does not exist");
>       }
>       return false;
>     } else if (iip.length() == 1) { // src is the root
>       NameNode.stateChangeLog.warn(
>           "DIR* FSDirectory.unprotectedDelete: failed to remove " +
>               iip.getPath() + " because the root is not allowed to be 
> deleted");
>       return false;
>     }
>     return true;
>   }
> {code}
> Through the code of deleteAllowed, we can find that when src is the root, it 
> can return false.
> So without this PR, when I execute *bin/hdfs dfs -rm -r /*
> I find the confusing auditlog line like following
> 2020-11-05 14:32:53,420 INFO  FSNamesystem.audit 
> (FSNamesystem.java:logAuditMessage(8102)) - allowed=true



--
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