فهرست منبع

[compute][discovery] check service-discovery cm for ldapgroup

We currently dig into Hive and Impala config files to find the ldap
groups. The parsing of hive and impala config file is error prone. Even
bigger issue is that we expect a comma-separated list of groups but it
is not guaranteed. Certain Impala environments can had a ldap-filter
there in place of comma-separated list of groups.

This change prioritizes checking the service-discovery configmap to
pick the ldapGroups info.
Amit Srivastava 8 ماه پیش
والد
کامیت
dec03b4251
1فایلهای تغییر یافته به همراه19 افزوده شده و 6 حذف شده
  1. 19 6
      desktop/core/src/desktop/management/commands/sync_warehouses.py

+ 19 - 6
desktop/core/src/desktop/management/commands/sync_warehouses.py

@@ -140,9 +140,16 @@ def update_hive_configs(namespace, hive, host, port=80):
 
   hive_configs = core_v1.read_namespaced_config_map('hive-conf-hiveserver2', namespace)
   hive_site_data = confparse.ConfParse(hive_configs.data['hive-site.xml'])
-  ldap_groups = hive_site_data.get('hive.server2.authentication.ldap.groupFilter', '')
   hive_metastore_uris = hive_site_data.get('hive.metastore.uris')
 
+  # We prioritize getting the ldapGroups from the service-discovery configmap.
+  # If there is no information found in service discovery, we switch to using hive-site
+  service_discovery_cm = core_v1.read_namespaced_config_map('service-discovery-metadata', namespace)
+  ldap_groups = service_discovery_cm.data.get('ldapGroups') if service_discovery_cm else None
+  if ldap_groups is None:
+    LOG.debug('ldap groups not found in cm/service-discovery-metadata for ns: %s' % namespace)
+    ldap_groups = hive_site_data.get('hive.server2.authentication.ldap.groupFilter', '')
+
   settings = [
     {"name": "server_host", "value": host},
     {"name": "server_port", "value": port},
@@ -207,11 +214,17 @@ def update_impala_configs(namespace, impala, host):
   hive_site_data = confparse.ConfParse(hive_configs.data['hive-site.xml'])
   hive_metastore_uris = hive_site_data.get('hive.metastore.uris')
 
-  impala_flag_file = core_v1.read_namespaced_config_map('impala-coordinator-flagfile', namespace)
-  flag_file_data = impala_flag_file.data['flagfile']
-  ldap_regex = r'--ldap_group_filter=(.*)'
-  match = re.search(ldap_regex, flag_file_data)
-  ldap_groups = match.group(1) if match and match.group(1) else None
+  # We prioritize getting the ldapGroups from the service-discovery configmap.
+  # If there is no information found in service discovery, we switch to using impala-coordinator-flagfile
+  service_discovery_cm = core_v1.read_namespaced_config_map('service-discovery-metadata', namespace)
+  ldap_groups = service_discovery_cm.data.get('ldapGroups') if service_discovery_cm else None
+  if ldap_groups is None:
+    LOG.debug('ldap groups not found in cm/service-discovery-metadata for ns: %s' % namespace)
+    impala_flag_file = core_v1.read_namespaced_config_map('impala-coordinator-flagfile', namespace)
+    flag_file_data = impala_flag_file.data['flagfile']
+    ldap_regex = r'--ldap_group_filter=(.*)'
+    match = re.search(ldap_regex, flag_file_data)
+    ldap_groups = match.group(1) if match and match.group(1) else None
 
   settings = [
     {"name": "server_host", "value": host},