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/09/15 17:29:06 UTC

[GitHub] [hadoop] sunchao commented on a change in pull request #2281: HDFS-15516.Add info for create flags in NameNode audit logs.

sunchao commented on a change in pull request #2281:
URL: https://github.com/apache/hadoop/pull/2281#discussion_r488839078



##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
##########
@@ -2639,10 +2639,11 @@ HdfsFileStatus startFile(String src, PermissionStatus permissions,
           createParent, replication, blockSize, supportedVersions, ecPolicyName,
           storagePolicy, logRetryCache);
     } catch (AccessControlException e) {
-      logAuditEvent(false, "create", src);
+      logAuditEvent(false, "create(options=" + flag.toString() + ")", src);

Review comment:
       can we leave a space after "create" so it is consistent with rename? e.g., "create (options=..."

##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogger.java
##########
@@ -231,6 +232,30 @@ public void testAuditLoggerWithSetPermission() throws IOException {
     }
   }
 
+  @Test
+  public void testAuditLoggerWithCreateFlag() throws IOException {
+    final Configuration conf = new HdfsConfiguration();
+    final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
+    LogCapturer auditlog = LogCapturer.captureLogs(FSNamesystem.auditLog);
+    try {
+      cluster.waitClusterUp();
+      auditlog.clearOutput();
+      final FileSystem fs = cluster.getFileSystem();
+      final Path p = new Path("/debug.log");
+      FSDataOutputStream stm = fs.create(p);
+      assertTrue(auditlog.getOutput().contains("create(options"));

Review comment:
       can we test a few more cases? e.g., with or without flag, and check whether the content of the flag is actually logged correctly.




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