Repository: hbase Updated Branches: refs/heads/branch-1 3ed765257 -> d7c6a0bf4
HBASE-18512, Region Server will abort with IllegalStateException if HDFS umask has limited scope Signed-off-by: tedyu <yuzhih...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d7c6a0bf Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d7c6a0bf Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d7c6a0bf Branch: refs/heads/branch-1 Commit: d7c6a0bf43d6658593e62725359a093e584200c5 Parents: 3ed7652 Author: Pankaj Kumar <pankaj...@huawei.com> Authored: Mon Aug 14 21:27:45 2017 +0800 Committer: tedyu <yuzhih...@gmail.com> Committed: Tue Aug 15 13:26:28 2017 -0700 ---------------------------------------------------------------------- .../security/access/SecureBulkLoadEndpoint.java | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/d7c6a0bf/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java index 90bd96b..9670684 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java @@ -149,15 +149,26 @@ public class SecureBulkLoadEndpoint extends SecureBulkLoadService fs = baseStagingDir.getFileSystem(conf); if (!fs.exists(baseStagingDir)) { fs.mkdirs(baseStagingDir, PERM_HIDDEN); - } else { - fs.setPermission(baseStagingDir, PERM_HIDDEN); } - //no sticky bit in hadoop-1.0, making directory nonempty so it never gets erased - fs.mkdirs(new Path(baseStagingDir,"DONOTERASE"), PERM_HIDDEN); FileStatus status = fs.getFileStatus(baseStagingDir); - if(status == null) { + if (status == null) { throw new IllegalStateException("Failed to create staging directory"); } + + // If HDFS UMASK value has limited scope then staging directory permission may not be 711 + // after creation, so we should set staging directory permission explicitly. + if (!status.getPermission().equals(PERM_HIDDEN)) { + fs.setPermission(baseStagingDir, PERM_HIDDEN); + status = fs.getFileStatus(baseStagingDir); + } + + // no sticky bit in hadoop-1.0, making directory nonempty so it never gets erased + Path doNotEraseDir = new Path(baseStagingDir, "DONOTERASE"); + if (!fs.exists(doNotEraseDir)) { + fs.mkdirs(doNotEraseDir, PERM_HIDDEN); + fs.setPermission(doNotEraseDir, PERM_HIDDEN); + } + String scheme = fs.getScheme().toLowerCase(); if (!fsSet.contains(scheme) && !status.getPermission().equals(PERM_HIDDEN)) { throw new IllegalStateException(