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

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

                Author: ASF GitHub Bot
            Created on: 30/Aug/21 14:59
            Start Date: 30/Aug/21 14:59
    Worklog Time Spent: 10m 
      Work Description: umamaheswararao commented on a change in pull request 
#3353:
URL: https://github.com/apache/hadoop/pull/3353#discussion_r698559465



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestViewDistributedFileSystem.java
##########
@@ -89,4 +91,30 @@ public void testEmptyDelegationToken() throws IOException {
       }
     }
   }
+
+  @Test
+  public void testRenameWithOptions() throws IOException {
+    Configuration conf = getTestConfiguration();
+    MiniDFSCluster cluster = null;
+    try {
+      cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
+      URI defaultUri =
+          URI.create(conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY));
+      conf.set("fs.viewfs.mounttable." + defaultUri.getHost() + 
".linkFallback",
+          defaultUri.toString());
+      conf.setLong(CommonConfigurationKeys.FS_TRASH_INTERVAL_KEY, 30000);
+      try (ViewDistributedFileSystem fileSystem =
+          (ViewDistributedFileSystem) FileSystem.get(conf)) {
+        final Path testDir = new Path("/test");
+        final Path renameDir = new Path("/testRename");
+        fileSystem.mkdirs(testDir);
+        fileSystem.rename(testDir, renameDir, Options.Rename.TO_TRASH);
+        Assert.assertTrue(fileSystem.exists(renameDir));

Review comment:
       @jojochuang The root cause for this issue is not really due to trash 
right. Issue is with rename with options API itself. Irrespective of the 
options flag, Issue comes. So, just passed To_trash flag as started debug 
through that API. In trash case the target dir formed by TrashDefaultPolicy. In 
this test I am giving my own target. Here rename responsibility is to do raname 
to the given path. So, I am asserting to my given dir. NN using this flags to 
do some additional checks at server. 
   
   ex: In FSDirRenameOp
   
   ```
   if(renameToTrash) {
           // if destination is the trash directory,
           // besides the permission check on "rename"
           // we need to enforce the check for "delete"
           // otherwise, it would expose a
           // security hole that stuff moved to trash
           // will be deleted by superuser
           fsd.checkPermission(pc, srcIIP, false, null, FsAction.WRITE, null,
               FsAction.ALL, true);
         } else {
           // Rename does not operate on link targets
           // Do not resolveLink when checking permissions of src and dst
           // Check write access to parent of src
           fsd.checkPermission(pc, srcIIP, false, null, FsAction.WRITE, null,
               null, false);
         }
   ```
   Let me know if you are still concern with the flag, I can change it to 
overwrite flag. We can also add moveToTrash API ( Once we know the root cause, 
I thought my test should focus on cause.) I tested manually trash and it worked.
   




-- 
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: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

    Worklog Id:     (was: 643504)
    Time Spent: 1h 10m  (was: 1h)

> ViewDistributedFileSystem#rename wrongly using src in the place of dst.
> -----------------------------------------------------------------------
>
>                 Key: HDFS-16192
>                 URL: https://issues.apache.org/jira/browse/HDFS-16192
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>            Reporter: Uma Maheswara Rao G
>            Assignee: Uma Maheswara Rao G
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> In ViewDistributedFileSystem, we are mistakenly used src path in the place of 
> dst path when finding mount path info.



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