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 "ayushtkn (via GitHub)" <gi...@apache.org> on 2023/05/10 07:47:41 UTC

[GitHub] [hadoop] ayushtkn commented on a diff in pull request #5552: HDFS-16979. RBF: Add proxyuser port in hdfsauditlog

ayushtkn commented on code in PR #5552:
URL: https://github.com/apache/hadoop/pull/5552#discussion_r1189473819


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java:
##########
@@ -462,13 +462,24 @@ private void appendClientPortToCallerContextIfAbsent() {
               .setSignature(origSignature)
               .build());
     }
+    ctx = CallerContext.getCurrent();
+    if (isFormProxyUser(ctx)) {
+      CallerContext.setCurrent(
+          new CallerContext.Builder(ctx.getContext(), contextFieldSeparator)
+              .append(CallerContext.PROXY_USER_PORT, String.valueOf(Server.getRemotePort()))
+              .setSignature(ctx.getSignature())
+              .build());
+    }
   }
 
   private boolean isClientPortInfoAbsent(CallerContext ctx){
     return ctx == null || ctx.getContext() == null
         || !ctx.getContext().contains(CallerContext.CLIENT_PORT_STR);
   }
 
+  private boolean isFormProxyUser(CallerContext ctx) {
+    return ctx != null && ctx.getContext().contains(CallerContext.REAL_USER_STR);
+  }

Review Comment:
   typo: form -> from
   Add a null check for getContext as well.
   ```
     private boolean isFromProxyUser(CallerContext ctx) {
       return ctx != null && ctx.getContext() != null && ctx.getContext()
           .contains(CallerContext.REAL_USER_STR);
     }
   ```



##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java:
##########
@@ -2116,6 +2121,8 @@ public void testRealUserPropagationInCallerContext()
     // Real user is added to the caller context.
     assertTrue("The audit log should contain the real user.",
         logOutput.contains(String.format("realUser:%s", realUser.getUserName())));
+    assertTrue("The audit log should contain the proxyuser port.",
+        logOutput.contains(PROXY_USER_PORT));

Review Comment:
   can you assert the router port as well? There are 2 routers and it should be either of them?



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