Преглед изворни кода

[raz] Add flag for autocreation of user directories (#3048)

- By default, the flag is turned on.
Harsh Gupta пре 3 година
родитељ
комит
67aeea75e8

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

@@ -928,6 +928,8 @@ tls=no
 ## How to authenticate against: KERBEROS or JWT (not supported yet)
 # api_authentication=KERBEROS
 
+## Autocreate the user home directory in the remote home storage path.
+# autocreate_user_dir=true
 
 ###########################################################################
 # Settings to configure the snippets available in the Notebook

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

@@ -911,6 +911,8 @@
   ## How to authenticate against: KERBEROS or JWT (not supported yet)
   # api_authentication=KERBEROS
 
+  ## Autocreate the user home directory in the remote home storage path.
+  # autocreate_user_dir=true
 
 ###########################################################################
 # Settings to configure the snippets available in the Notebook

+ 6 - 0
desktop/core/src/desktop/conf.py

@@ -2156,6 +2156,12 @@ RAZ = ConfigSection(
         type=coerce_str_lowercase,
         default='kerberos',
     ),
+    AUTOCREATE_USER_DIR=Config(
+      key='autocreate_user_dir',
+      help=_('Autocreate the user home directory in the remote storage home path.'),
+      type=coerce_bool,
+      default=True,
+    ),
   )
 )
 

+ 3 - 1
desktop/core/src/desktop/lib/fs/proxyfs.py

@@ -210,6 +210,8 @@ class ProxyFS(object):
     Initially home_path will have path value for HDFS and if it is configured in Hue, try creating the user home dir for it first.
     Then we check if S3/ABFS is configured in Hue via RAZ. If yes, try creating user home dir for them next.
     """
+    from desktop.conf import RAZ # Imported dynamically in order to have proper value.
+
     if home_path is None:
       home_path = self.get_home_dir()
 
@@ -230,7 +232,7 @@ class ProxyFS(object):
     request = CrequestMiddleware.get_request()
     username = request.user.username if request and hasattr(request, 'user') and request.user.is_authenticated else self.getuser()
 
-    if is_raz_s3() or is_raz_abfs():
+    if RAZ.AUTOCREATE_USER_DIR.get() and (is_raz_s3() or is_raz_abfs()):
       fs = self.do_as_user(username, self._get_fs, home_path)
       fs.create_home_dir(home_path)