Просмотр исходного кода

[hdfs] Add a config flag to cleanly disable while using connectors

For historical reason there is no way to disable HDFS.
Romain Rigaux 4 лет назад
Родитель
Сommit
d5aede2c96

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

@@ -1147,6 +1147,9 @@
       # Directory of the Hadoop configuration
       ## hadoop_conf_dir=$HADOOP_CONF_DIR when set or '/etc/hadoop/conf'
 
+      # Whether Hue should list this HDFS cluster. For historical reason there is no way to disable HDFS.
+      ## is_enabled=true
+
   # Configuration for YARN (MR2)
   # ------------------------------------------------------------------------
   [[yarn_clusters]]

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

@@ -1131,6 +1131,9 @@
       # Directory of the Hadoop configuration
       ## hadoop_conf_dir=$HADOOP_CONF_DIR when set or '/etc/hadoop/conf'
 
+      # Whether Hue should list this HDFS cluster. For historical reason there is no way to disable HDFS.
+      ## is_enabled=true
+
   # Configuration for YARN (MR2)
   # ------------------------------------------------------------------------
   [[yarn_clusters]]

+ 10 - 4
desktop/libs/hadoop/src/hadoop/conf.py

@@ -118,10 +118,16 @@ HDFS_CLUSTERS = UnspecifiedConfigSection(
           type=str
       ),
       HADOOP_CONF_DIR = Config(
-        key="hadoop_conf_dir",
-        dynamic_default=get_hadoop_conf_dir_default,
-        help=_t("Directory of the Hadoop configuration) Defaults to the environment variable HADOOP_CONF_DIR when set, or '/etc/hadoop/conf'.")
-      )
+          key="hadoop_conf_dir",
+          dynamic_default=get_hadoop_conf_dir_default,
+          help="Directory of the Hadoop configuration) Defaults to the environment variable HADOOP_CONF_DIR when set, or '/etc/hadoop/conf'."
+      ),
+      IS_ENABLED=Config(
+          'is_enabled',
+          help="Whether Hue should list this HDFS cluster. For historical reason there is no way to disable HDFS.",
+          default=True,  # True here for backward compatibility
+          type=coerce_bool
+      ),
     )
   )
 )

+ 3 - 0
desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

@@ -1039,6 +1039,9 @@ def test_fs_configuration(fs_config):
   """
   This is a config validation method. Returns a list of [(config_variable, error_message)].
   """
+  if not fs_config.IS_ENABLED.get():
+    return []
+
   fs = WebHdfs.from_config(fs_config)
   fs.setuser(fs.superuser)