You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2023/01/12 21:49:43 UTC

[hadoop] branch branch-3.3 updated: MAPREDUCE-7375 JobSubmissionFiles don't set right permission after mkdirs (#4237)

This is an automated email from the ASF dual-hosted git repository.

cnauroth pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new eef2fdcc29e MAPREDUCE-7375 JobSubmissionFiles don't set right permission after mkdirs (#4237)
eef2fdcc29e is described below

commit eef2fdcc29e949a8001bc075219e68de5d4832bd
Author: skysiders <64...@users.noreply.github.com>
AuthorDate: Fri Jan 13 05:48:29 2023 +0800

    MAPREDUCE-7375 JobSubmissionFiles don't set right permission after mkdirs (#4237)
    
    Signed-off-by: Chris Nauroth <cn...@apache.org>
    (cherry picked from commit 36bf54aba0fefa0f3e94d94f836ab054d31ec5c9)
---
 .../hadoop/mapreduce/JobSubmissionFiles.java       |  2 +-
 .../hadoop/mapreduce/TestJobSubmissionFiles.java   | 25 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmissionFiles.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmissionFiles.java
index f6e66db2369..fffcb896091 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmissionFiles.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmissionFiles.java
@@ -159,7 +159,7 @@ public class JobSubmissionFiles {
         fs.setPermission(stagingArea, JOB_DIR_PERMISSION);
       }
     } catch (FileNotFoundException e) {
-      fs.mkdirs(stagingArea, new FsPermission(JOB_DIR_PERMISSION));
+      FileSystem.mkdirs(fs, stagingArea, new FsPermission(JOB_DIR_PERMISSION));
     }
     return stagingArea;
   }
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJobSubmissionFiles.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJobSubmissionFiles.java
index ab3f7a0a937..6e9c80813fc 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJobSubmissionFiles.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJobSubmissionFiles.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.mapreduce;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystemTestHelper;
@@ -33,6 +34,8 @@ import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.hdfs.HdfsConfiguration;
 /**
  * Tests for JobSubmissionFiles Utility class.
  */
@@ -139,4 +142,26 @@ public class TestJobSubmissionFiles {
     assertEquals(stagingPath,
         JobSubmissionFiles.getStagingDir(cluster, conf, user));
   }
+
+  @Test
+  public void testDirPermission() throws Exception {
+    Cluster cluster = mock(Cluster.class);
+    HdfsConfiguration conf = new HdfsConfiguration();
+    conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "700");
+    MiniDFSCluster dfsCluster = null;
+    try {
+      dfsCluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
+      FileSystem fs = dfsCluster.getFileSystem();
+      UserGroupInformation user = UserGroupInformation
+          .createUserForTesting(USER_1_SHORT_NAME, GROUP_NAMES);
+      Path stagingPath = new Path(fs.getUri().toString() + "/testDirPermission");
+      when(cluster.getStagingAreaDir()).thenReturn(stagingPath);
+      Path res = JobSubmissionFiles.getStagingDir(cluster, conf, user);
+      assertEquals(new FsPermission(0700), fs.getFileStatus(res).getPermission());
+    } finally {
+      if (dfsCluster != null) {
+        dfsCluster.shutdown();
+      }
+    }
+  }
 }


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