You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/10/24 17:46:51 UTC

[GitHub] [hadoop] mkuchenbecker commented on a diff in pull request #5071: HDFS-16816 RBF: auto-create user home dir for trash paths by router

mkuchenbecker commented on code in PR #5071:
URL: https://github.com/apache/hadoop/pull/5071#discussion_r1003591256


##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java:
##########
@@ -723,6 +723,49 @@ public boolean delete(String src, boolean recursive) throws IOException {
     }
   }
 
+  // Create missing user home dirs for trash paths.
+  // We assume the router is running with super-user privilege (can create
+  // user home dir in /user dir).
+  private void createUserHomeForTrashPath(List<RemoteLocation> locations) throws IOException {
+    List<RemoteLocation> missingUserHomes = new ArrayList<>();
+
+    // Identify missing trash roots
+    for(RemoteLocation loc: locations) {
+
+      String path = loc.getDest();
+      // Continue if not a trash path
+      if (!MountTableResolver.isTrashPath(path)) {
+        continue;
+      }
+
+      // Check whether user home dir exists at the destination namespace
+      String trashRoot = MountTableResolver.getTrashRoot();
+      String userHome = new Path(trashRoot).getParent().toUri().getPath();
+      RemoteLocation userHomeLoc = new RemoteLocation(loc, userHome);
+      RemoteMethod method = new RemoteMethod("getFileInfo", new Class<?>[] {String.class}, new RemoteParam());
+      HdfsFileStatus ret = rpcClient.invokeSingle(userHomeLoc, method, HdfsFileStatus.class);
+      if (ret == null) {
+        missingUserHomes.add(userHomeLoc);
+      }
+    }
+
+    if (!missingUserHomes.isEmpty()) {

Review Comment:
   Is this logic correct? When missingUserHomes is populated once while looping through locations this will always be true. 
   
   Should this instead be in a separate loop over missingUserHomes?



-- 
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-unsubscribe@hadoop.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org