Browse Source

[compute] Fixed warehouses sync for impala feng (#3465)

Impala unified-analytics (feng) presents a Hive interface and should go in Hive editor rather than Impala editor.

Change-Id: Ifa5d5f40a5f53ccaccdbed49f11354dffbbaa44c
Amit S 2 years ago
parent
commit
40f2b2b5ab
1 changed files with 10 additions and 9 deletions
  1. 10 9
      desktop/core/src/desktop/management/commands/sync_warehouses.py

+ 10 - 9
desktop/core/src/desktop/management/commands/sync_warehouses.py

@@ -57,7 +57,10 @@ class Command(BaseCommand):
 
 
 
 
 def sync_warehouses(args, options):
 def sync_warehouses(args, options):
-  (hives, impalas) = get_computes_from_k8s()
+  computes = get_computes_from_k8s()
+
+  hives = [c for c in computes if c['dialect'] == 'hive']
+  impalas = [c for c in computes if c['dialect'] == 'impala']
 
 
   (hive_warehouse, created) = models.Namespace.objects.get_or_create(
   (hive_warehouse, created) = models.Namespace.objects.get_or_create(
     external_id="CDW_HIVE_WAREHOUSE",
     external_id="CDW_HIVE_WAREHOUSE",
@@ -89,9 +92,7 @@ if __name__ == '__main__':
 
 
 def get_computes_from_k8s():
 def get_computes_from_k8s():
   catalogs = []
   catalogs = []
-  hives = []
-  impalas = []
-  computes = {}
+  computes = []
 
 
   for n in core_v1.list_namespace().items:
   for n in core_v1.list_namespace().items:
     namespace = n.metadata.name
     namespace = n.metadata.name
@@ -105,15 +106,13 @@ def get_computes_from_k8s():
     if namespace.startswith('warehouse-'):
     if namespace.startswith('warehouse-'):
       catalogs.append(item)
       catalogs.append(item)
     elif namespace.startswith('compute-'):
     elif namespace.startswith('compute-'):
-      hives.append(item)
-      computes[namespace] = item
+      computes.append(item)
       update_hive_configs(namespace, item, 'hiveserver2-service.%s.svc.cluster.local' % namespace)
       update_hive_configs(namespace, item, 'hiveserver2-service.%s.svc.cluster.local' % namespace)
     elif namespace.startswith('impala-'):
     elif namespace.startswith('impala-'):
-      impalas.append(item)
-      computes[namespace] = item
+      computes.append(item)
       populate_impala(namespace, item)
       populate_impala(namespace, item)
 
 
-  return (hives, impalas)
+  return computes
 
 
 def update_hive_configs(namespace, hive, host, port=80):
 def update_hive_configs(namespace, hive, host, port=80):
   hs2_stfs = apps_v1.read_namespaced_stateful_set('hiveserver2', namespace)
   hs2_stfs = apps_v1.read_namespaced_stateful_set('hiveserver2', namespace)
@@ -204,6 +203,8 @@ def update_impala_configs(namespace, impala, host):
     {"name": "hive_metastore_uris", "value": hive_metastore_uris},
     {"name": "hive_metastore_uris", "value": hive_metastore_uris},
   ]
   ]
 
 
+  impala.pop('server_port', None)
+  impala.pop('api_port', None)
   impala.update({
   impala.update({
     'dialect': 'impala',
     'dialect': 'impala',
     'interface': 'hiveserver2',
     'interface': 'hiveserver2',