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 2020/10/06 17:06:41 UTC

[GitHub] [hadoop] ferhui commented on a change in pull request #2363: HDFS-13293. RBF: The RouterRPCServer should transfer CallerContext an…

ferhui commented on a change in pull request #2363:
URL: https://github.com/apache/hadoop/pull/2363#discussion_r500454655



##########
File path: hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
##########
@@ -519,6 +525,21 @@ private Object invokeMethod(
     }
   }
 
+  /**
+   * For Tracking which is the actual client address.
+   * It adds key/value (clientIp/"ip") pair to the caller context.
+   */
+  private void appendClientIp2CallerContext() {
+    final CallerContext ctx = CallerContext.getCurrent();
+    CallerContext.Builder builder;
+    String origContext = ctx == null ? null : ctx.getContext();
+    byte[] origSignature = ctx == null ? null : ctx.getSignature();
+    builder = new CallerContext.Builder(origContext, clientConf);
+    builder.append(CLIENT_IP_STR, Server.getRemoteAddress());
+    builder.setSignature(origSignature);
+    CallerContext.setCurrent(builder.build());

Review comment:
       Ok

##########
File path: hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
##########
@@ -519,6 +525,21 @@ private Object invokeMethod(
     }
   }
 
+  /**
+   * For Tracking which is the actual client address.
+   * It adds key/value (clientIp/"ip") pair to the caller context.
+   */
+  private void appendClientIp2CallerContext() {
+    final CallerContext ctx = CallerContext.getCurrent();
+    CallerContext.Builder builder;

Review comment:
       Ok

##########
File path: hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
##########
@@ -1901,4 +1903,19 @@ private DFSClient getFileDFSClient(final String path) {
     }
     return null;
   }
+
+  @Test
+  public void testCreateWithCallerContext() throws IOException {
+    GenericTestUtils.LogCapturer auditlog =
+        GenericTestUtils.LogCapturer.captureLogs(FSNamesystem.auditLog);
+
+    // Create a directory via the router
+    String dirPath = "/test_dir_with_callercontext";
+    FsPermission permission = new FsPermission("705");
+    routerProtocol.mkdirs(dirPath, permission, false);
+
+    // The audit log should contains "callerContext=clientIp:"
+    assertTrue(auditlog.getOutput().contains("callerContext=clientIp:"));

Review comment:
       old context is null, Will add a check.

##########
File path: hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
##########
@@ -404,6 +409,7 @@ private Object invokeMethod(
           " with params " + Arrays.deepToString(params) + " from "
           + router.getRouterId());
     }
+    appendClientIp2CallerContext();

Review comment:
       ok

##########
File path: hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
##########
@@ -116,10 +118,13 @@
   /** Optional perf monitor. */
   private final RouterRpcMonitor rpcMonitor;
 
+  private final Configuration clientConf;
+
   /** Pattern to parse a stack trace line. */
   private static final Pattern STACK_TRACE_PATTERN =
       Pattern.compile("\\tat (.*)\\.(.*)\\((.*):(\\d*)\\)");
 
+  private static final String CLIENT_IP_STR = "clientIp";

Review comment:
       Now don't know Whether add anything else except client ip, any thoughts?




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