Hadoop HDFS
  1. Hadoop HDFS
  2. HDFS-3890

filecontext mkdirs doesn't apply umask as expected

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 0.23.3
    • Fix Version/s: 0.23.3, 2.0.2-alpha
    • Component/s: None
    • Labels:
      None

      Description

      I was attempting to set the umask of my fileContext and then do a mkdirs, but the umask wasn't applied as expected.

      doneDirFc = FileContext.getFileContext(doneDirPrefixPath.toUri(), conf);
      doneDirFc.setUMask(JobHistoryUtils.HISTORY_DONE_DIR_UMASK);
      doneDirFc.mkdir(path, fsp, true);

      It appears to be using the default umask set in the conf (fs.permissions.umask-mode) and overrode the umask I set in fileContext. I had the default umask set to 077 and set the filecontext umask to 007. The permissions on the directories it created were all rwx------.

      1. HDFS-3890.patch
        13 kB
        Thomas Graves
      2. HDFS-3890.patch
        12 kB
        Thomas Graves
      3. HDFS-3890.patch
        2 kB
        Thomas Graves

        Issue Links

          Activity

          Hide
          Thomas Graves added a comment -

          It appears what is happening is fileContext.mkdirs calls into hdfs.mkdirs, which calls the DFSClient.mkdirs. DFSClient is applying the umask from the conf. I think hdfs.mkdirs needs to call primitiveMkdir, although primitiveMkdir is missing the create Parent flag, so I believe a new primitiveMkdir function should be created which has the extra createParent boolean flag.

          I'm attaching a patch with these changes that I tested in my usecase. It still needs unit tests but folks can look at it and see if its the right things to do.

          Show
          Thomas Graves added a comment - It appears what is happening is fileContext.mkdirs calls into hdfs.mkdirs, which calls the DFSClient.mkdirs. DFSClient is applying the umask from the conf. I think hdfs.mkdirs needs to call primitiveMkdir, although primitiveMkdir is missing the create Parent flag, so I believe a new primitiveMkdir function should be created which has the extra createParent boolean flag. I'm attaching a patch with these changes that I tested in my usecase. It still needs unit tests but folks can look at it and see if its the right things to do.
          Hide
          Daryn Sharp added a comment -

          Looks good me. This mimics the behavior of other FC methods like create whereby it applies the umask of the context, and then uses a primitive method to avoid DFSClient re-applying the default umask.

          Show
          Daryn Sharp added a comment - Looks good me. This mimics the behavior of other FC methods like create whereby it applies the umask of the context, and then uses a primitive method to avoid DFSClient re-applying the default umask.
          Hide
          Todd Lipcon added a comment -

          Looks good, good catch, but needs a unit test.

          Show
          Todd Lipcon added a comment - Looks good, good catch, but needs a unit test.
          Hide
          Thomas Graves added a comment -

          Thanks Todd and Daryn. Since it the approach sounds reasonable to you here is the complete patch with unit tests.

          Show
          Thomas Graves added a comment - Thanks Todd and Daryn. Since it the approach sounds reasonable to you here is the complete patch with unit tests.
          Hide
          Thomas Graves added a comment -

          A couple unit tests were failing because it was unwrapping different exceptions. Fixing that.

          Show
          Thomas Graves added a comment - A couple unit tests were failing because it was unwrapping different exceptions. Fixing that.
          Hide
          Hadoop QA added a comment -

          +1 overall. Here are the results of testing the latest attachment
          http://issues.apache.org/jira/secure/attachment/12543931/HDFS-3890.patch
          against trunk revision .

          +1 @author. The patch does not contain any @author tags.

          +1 tests included. The patch appears to include 1 new or modified test files.

          +1 javac. The applied patch does not increase the total number of javac compiler warnings.

          +1 javadoc. The javadoc tool did not generate any warning messages.

          +1 eclipse:eclipse. The patch built with eclipse:eclipse.

          +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

          +1 release audit. The applied patch does not increase the total number of release audit warnings.

          +1 core tests. The patch passed unit tests in hadoop-hdfs-project/hadoop-hdfs.

          +1 contrib tests. The patch passed contrib unit tests.

          Test results: https://builds.apache.org/job/PreCommit-HDFS-Build/3151//testReport/
          Console output: https://builds.apache.org/job/PreCommit-HDFS-Build/3151//console

          This message is automatically generated.

          Show
          Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12543931/HDFS-3890.patch against trunk revision . +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 1 new or modified test files. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 javadoc. The javadoc tool did not generate any warning messages. +1 eclipse:eclipse. The patch built with eclipse:eclipse. +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed unit tests in hadoop-hdfs-project/hadoop-hdfs. +1 contrib tests. The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-HDFS-Build/3151//testReport/ Console output: https://builds.apache.org/job/PreCommit-HDFS-Build/3151//console This message is automatically generated.
          Hide
          Daryn Sharp added a comment -

          +1 Nice set of tests!

          Show
          Daryn Sharp added a comment - +1 Nice set of tests!
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Hdfs-trunk-Commit #2755 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk-Commit/2755/)
          HDFS-3890. filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606)

          Result = SUCCESS
          daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606
          Files :

          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Show
          Hudson added a comment - Integrated in Hadoop-Hdfs-trunk-Commit #2755 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk-Commit/2755/ ) HDFS-3890 . filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606) Result = SUCCESS daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606 Files : /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Common-trunk-Commit #2692 (See https://builds.apache.org/job/Hadoop-Common-trunk-Commit/2692/)
          HDFS-3890. filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606)

          Result = SUCCESS
          daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606
          Files :

          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Show
          Hudson added a comment - Integrated in Hadoop-Common-trunk-Commit #2692 (See https://builds.apache.org/job/Hadoop-Common-trunk-Commit/2692/ ) HDFS-3890 . filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606) Result = SUCCESS daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606 Files : /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Hide
          Daryn Sharp added a comment -

          I've committed to trunk, branch 2 & 23.3. Thanks Tom!

          Show
          Daryn Sharp added a comment - I've committed to trunk, branch 2 & 23.3. Thanks Tom!
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Mapreduce-trunk-Commit #2716 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk-Commit/2716/)
          HDFS-3890. filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606)

          Result = FAILURE
          daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606
          Files :

          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Show
          Hudson added a comment - Integrated in Hadoop-Mapreduce-trunk-Commit #2716 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk-Commit/2716/ ) HDFS-3890 . filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606) Result = FAILURE daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606 Files : /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Hdfs-trunk #1158 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk/1158/)
          HDFS-3890. filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606)

          Result = FAILURE
          daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606
          Files :

          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Show
          Hudson added a comment - Integrated in Hadoop-Hdfs-trunk #1158 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk/1158/ ) HDFS-3890 . filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606) Result = FAILURE daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606 Files : /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Mapreduce-trunk #1189 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk/1189/)
          HDFS-3890. filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606)

          Result = SUCCESS
          daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606
          Files :

          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
          • /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Show
          Hudson added a comment - Integrated in Hadoop-Mapreduce-trunk #1189 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk/1189/ ) HDFS-3890 . filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381606) Result = SUCCESS daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381606 Files : /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Hdfs-0.23-Build #367 (See https://builds.apache.org/job/Hadoop-Hdfs-0.23-Build/367/)
          svn merge -c 1381606 FIXES: HDFS-3890. filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381610)

          Result = UNSTABLE
          daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381610
          Files :

          • /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
          • /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
          • /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
          • /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java
          Show
          Hudson added a comment - Integrated in Hadoop-Hdfs-0.23-Build #367 (See https://builds.apache.org/job/Hadoop-Hdfs-0.23-Build/367/ ) svn merge -c 1381606 FIXES: HDFS-3890 . filecontext mkdirs doesn't apply umask as expected (Tom Graves via daryn) (Revision 1381610) Result = UNSTABLE daryn : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1381610 Files : /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java

            People

            • Assignee:
              Thomas Graves
              Reporter:
              Thomas Graves
            • Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development