Explorar o código

[hadoop] Read umask mode directly from the hdfs-site.xml

Romain Rigaux %!s(int64=10) %!d(string=hai) anos
pai
achega
dd4bcba

+ 0 - 3
desktop/conf.dist/hue.ini

@@ -654,9 +654,6 @@
       # Change this if your HDFS cluster is Kerberos-secured
       ## security_enabled=false
 
-      # Default umask for file and directory creation, specified in an octal value.
-      ## umask=022
-
       # Directory of the Hadoop configuration
       ## hadoop_conf_dir=$HADOOP_CONF_DIR when set or '/etc/hadoop/conf'
 

+ 0 - 3
desktop/conf/pseudo-distributed.ini.tmpl

@@ -657,9 +657,6 @@
       # Change this if your HDFS cluster is Kerberos-secured
       ## security_enabled=false
 
-      # Default umask for file and directory creation, specified in an octal value.
-      ## umask=022
-
       # Directory of the Hadoop configuration
       ## hadoop_conf_dir=$HADOOP_CONF_DIR when set or '/etc/hadoop/conf'
 

+ 0 - 9
desktop/libs/hadoop/src/hadoop/conf.py

@@ -40,13 +40,6 @@ def find_file_recursive(desired_glob, root):
   return f
 
 
-def coerce_umask(umask):
-  if len(umask) < 4:
-    umask = "1" + umask
-
-  return int(umask, 8)
-
-
 UPLOAD_CHUNK_SIZE = Config(
   key="upload_chunk_size",
   help="Size, in bytes, of the 'chunks' Django should store into memory and feed into the handler. Default is 64MB.",
@@ -76,8 +69,6 @@ HDFS_CLUSTERS = UnspecifiedConfigSection(
                               default=False, type=coerce_bool),
       TEMP_DIR=Config("temp_dir", help="HDFS directory for temporary files",
                       default='/tmp', type=str),
-      UMASK=Config("umask", help="Default umask for file and directory creation, specified in an octal value",
-                   default='022', type=coerce_umask),
       HADOOP_CONF_DIR = Config(
         key="hadoop_conf_dir",
         default=os.environ.get("HADOOP_CONF_DIR", "/etc/hadoop/conf"),

+ 2 - 2
desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

@@ -34,7 +34,7 @@ from hadoop.fs.hadoopfs import Hdfs
 from hadoop.fs.exceptions import WebHdfsException
 from hadoop.fs.webhdfs_types import WebHdfsStat, WebHdfsContentSummary
 from hadoop.conf import UPLOAD_CHUNK_SIZE
-from hadoop.hdfs_site import get_nn_sentry_prefixes
+from hadoop.hdfs_site import get_nn_sentry_prefixes, get_umask_mode
 
 import hadoop.conf
 import desktop.conf
@@ -86,7 +86,7 @@ class WebHdfs(Hdfs):
                logical_name=hdfs_config.LOGICAL_NAME.get(),
                security_enabled=hdfs_config.SECURITY_ENABLED.get(),
                temp_dir=hdfs_config.TEMP_DIR.get(),
-               umask=hdfs_config.UMASK.get())
+               umask=get_umask_mode())
 
   def __str__(self):
     return "WebHdfs at %s" % self._url

+ 14 - 4
desktop/libs/hadoop/src/hadoop/hdfs_site.py

@@ -27,8 +27,11 @@ LOG = logging.getLogger(__name__)
 
 _HDFS_SITE_DICT = None
 
+
+_CNF_NN_PERMISSIONS_UMASK_MODE = 'fs.permissions.umask-mode'
 _CNF_NN_SENTRY_PREFIX = 'sentry.authorization-provider.hdfs-path-prefixes'
 
+
 def reset():
   global _HDFS_SITE_DICT
   _HDFS_SITE_DICT = None
@@ -40,6 +43,17 @@ def get_conf():
   return _HDFS_SITE_DICT
 
 
+def get_umask_mode():
+  umask = get_conf().get(_CNF_NN_PERMISSIONS_UMASK_MODE, '022')
+  if len(umask) < 4:
+    umask = "1" + umask
+
+  return int(umask, 8)
+
+def get_nn_sentry_prefixes():
+  return get_conf().get(_CNF_NN_SENTRY_PREFIX, '')
+
+
 def _parse_hdfs_site():
   global _HDFS_SITE_DICT
   hdfs_site_path = ''
@@ -57,7 +71,3 @@ def _parse_hdfs_site():
     data = ""
 
   _HDFS_SITE_DICT = confparse.ConfParse(data)
-
-
-def get_nn_sentry_prefixes():
-  return get_conf().get(_CNF_NN_SENTRY_PREFIX, '')