Răsfoiți Sursa

HUE-5716 Add impalad_flags to impala conf and set dynamic default values

krish 8 ani în urmă
părinte
comite
480608a9b8

+ 3 - 2
apps/impala/src/impala/conf.py

@@ -27,6 +27,7 @@ from desktop.lib.conf import ConfigSection, Config, coerce_bool, coerce_csv, coe
 from desktop.lib.exceptions import StructuredThriftTransportException
 from desktop.lib.paths import get_desktop_root
 
+from impala.impala_flags import get_ssl_server_certificate, get_max_result_cache_size, is_impersonation_enabled
 from impala.settings import NICE_NAME
 
 
@@ -54,7 +55,7 @@ IMPERSONATION_ENABLED=Config(
   key='impersonation_enabled',
   help=_t("Turn on/off impersonation mechanism when talking to Impala."),
   type=coerce_bool,
-  default=False)
+  dynamic_default=is_impersonation_enabled)
 
 QUERYCACHE_ROWS=Config(
   key='querycache_rows',
@@ -62,7 +63,7 @@ QUERYCACHE_ROWS=Config(
           " support re-fetching them for downloading them."
           " Set to 0 for disabling the option and backward compatibility."),
   type=int,
-  default=50000)
+  dynamic_default=get_max_result_cache_size)
 
 SERVER_CONN_TIMEOUT = Config(
   key='server_conn_timeout',

+ 24 - 5
apps/impala/src/impala/impala_flags.py

@@ -19,8 +19,6 @@ import errno
 import logging
 import os.path
 
-from impala import conf
-
 LOG = logging.getLogger(__name__)
 
 _IMPALA_FLAGS = None
@@ -46,18 +44,39 @@ def get_webserver_certificate_file():
   return get_conf().get(_WEBSERVER_CERTIFICATE_FILE)
 
 def get_ssl_server_certificate():
+  """
+    The path to the TLS/SSL file containing the server certificate key used for TLS/SSL. Used when Catalog
+    Server Webserver is acting as a TLS/SSL server. The certificate file must be in PEM format.
+  """
   return get_conf().get(_SSL_SERVER_CERTIFICATE)
 
 def get_max_result_cache_size():
+  """
+    Maximum number of query results a client may request to be cached on a per-query basis to support restarting
+    fetches. This option guards against unreasonably large result caches requested by clients. Requests exceeding
+    this maximum will be rejected.
+  """
   result_size = get_conf().get(_MAX_RESULT_CACHE_SIZE)
-  return int(result_size) if result_size else None
-
+  return int(result_size) if result_size else 50000
 
 def get_authorized_proxy_user_config():
+  """
+    Specifies the set of authorized proxy users (users who can impersonate other users during authorization) and whom
+    they are allowed to impersonate. Input is a semicolon-separated list of key=value pairs of authorized proxy users
+    to the user(s) they can impersonate. These users are specified as a comma separated list of short usernames, or '*'
+    to indicate all users. For example: joe=alice,bob;hue=*;admin=*. Only valid when Sentry is enabled.
+  """
   return get_conf().get(_AUTHORIZED_PROXY_USER_CONFIG)
 
+def is_impersonation_enabled():
+  """
+    Returns True if user_config config contains 'hue='
+  """
+  user_config = get_conf().get(_AUTHORIZED_PROXY_USER_CONFIG)
+  return True if user_config and 'hue=' in user_config else False
 
 def _parse_impala_flags():
+  from impala import conf # Cyclic dependency
   global _IMPALA_FLAGS
 
   try:
@@ -69,4 +88,4 @@ def _parse_impala_flags():
     _IMPALA_FLAGS = {}
   except Exception, ex:
     LOG.error('Failed to parse Impala config from "%s": %s' % (impala_flags_path, ex))
-    _IMPALA_FLAGS = {}
+    _IMPALA_FLAGS = {}

+ 9 - 0
apps/impala/src/impala/test_impala_flags.py

@@ -33,6 +33,10 @@ def test_impala_flags():
   finish = None
 
   try:
+    assert_equal(conf.SSL.CACERTS.get(), None)
+    assert_equal(conf.QUERYCACHE_ROWS.get(), 50000)
+    assert_equal(conf.IMPERSONATION_ENABLED.get(), False)
+
     flags = """
       -webserver_certificate_file=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem
       -ssl_server_certificate=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem
@@ -48,6 +52,11 @@ def test_impala_flags():
     assert_equal(impala_flags.get_ssl_server_certificate(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem')
     assert_equal(impala_flags.get_max_result_cache_size(), 100000)
     assert_equal(impala_flags.get_authorized_proxy_user_config(), 'hue=*')
+
+    # From Config
+    assert_equal(conf.SSL.CACERTS.get(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem')
+    assert_equal(conf.QUERYCACHE_ROWS.get(), 100000)
+    assert_equal(conf.IMPERSONATION_ENABLED.get(), True)
   finally:
     impala_flags.reset()
     if finish: