瀏覽代碼

HUE-8591 [cluster] Step of logic simplification of the multi cluster configuration

Romain Rigaux 7 年之前
父節點
當前提交
b7b51716bd

+ 4 - 4
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -17,8 +17,8 @@
   from django.utils.translation import ugettext as _
 
   from desktop import conf
-  from desktop.models import ANALYTIC_DB
   from desktop.views import commonheader, commonfooter, _ko
+
   from jobbrowser.conf import DISABLE_KILLING_JOBS, MAX_JOB_FETCH, ENABLE_QUERY_BROWSER
 %>
 
@@ -1206,7 +1206,7 @@ ${ commonheader("Data Warehouse", "jobbrowser", user, request) | n,unicode }
       <i class="fa fa-refresh"></i>
     </a>
 
-    <button class="btn" title="${ _('Resize cluster') }" data-bind="enable: status() == 'ONLINE', visible: $root.compute() && $root.compute()['type'] == 'altus-dw2', toggle: updateClusterShow">
+    <button class="btn" title="${ _('Resize cluster') }" data-bind="enable: status() == 'ONLINE', visible: $root.cluster() && $root.cluster()['type'] == 'altus-dw2', toggle: updateClusterShow">
       <!-- ko if: updateClusterShow-->
         ${ _('Cancel') }
       <!-- /ko -->
@@ -2953,7 +2953,7 @@ ${ commonheader("Data Warehouse", "jobbrowser", user, request) | n,unicode }
 
       self.availableInterfaces = ko.pureComputed(function () {
         var jobsInterfaceCondition = function () {
-          return self.appConfig() && self.appConfig()['browser'] && self.appConfig()['browser']['interpreter_names'].indexOf('yarn') != -1 && self.clusterType() != '${ ANALYTIC_DB }' && (!self.cluster() || self.cluster()['type'].indexOf('altus') == -1);
+          return self.appConfig() && self.appConfig()['browser'] && self.appConfig()['browser']['interpreter_names'].indexOf('yarn') != -1 && (!self.cluster() || self.cluster()['type'].indexOf('altus') == -1);
         };
         var dataEngInterfaceCondition = function () {
           return self.cluster() && self.cluster()['type'] == 'altus-de';
@@ -2965,7 +2965,7 @@ ${ commonheader("Data Warehouse", "jobbrowser", user, request) | n,unicode }
           return self.cluster() && self.cluster()['type'] == 'altus-dw2';
         };
         var schedulerInterfaceCondition = function () {
-          return '${ user.has_hue_permission(action="access", app="oozie") }' == 'True' && self.clusterType() != '${ ANALYTIC_DB }' && (!self.cluster() || self.cluster()['type'].indexOf('altus') == -1);
+          return '${ user.has_hue_permission(action="access", app="oozie") }' == 'True' && (!self.cluster() || self.cluster()['type'].indexOf('altus') == -1);
         };
         var schedulerExtraInterfaceCondition = function () {
           return '${ is_mini }' == 'False' && schedulerInterfaceCondition();

+ 5 - 7
desktop/core/src/desktop/conf.py

@@ -1602,7 +1602,7 @@ IS_MULTICLUSTER_ONLY = Config(
 
 IS_K8_ONLY = Config(
   key='is_k8_only',
-  default=True,
+  default=False,
   type=coerce_bool,
   help=_('Choose whether to pick configs only from [desktop] [[cluster]]')
 )
@@ -1610,24 +1610,22 @@ IS_K8_ONLY = Config(
 
 def get_clusters(user):
   clusters = []
+  cluster_config = CLUSTERS.get()
 
   # Get core standalone config if there
-  apps = appmanager.get_apps_dict(user)
-  if 'beeswax' in apps: # and not IS_MULTICLUSTER_ONLY.get():
-    from beeswax.conf import HIVE_SERVER_HOST
+  if not IS_MULTICLUSTER_ONLY.get() or [cluster_config for i in cluster_config if i == 'Default']:
     clusters.append(
       (CLUSTER_ID.get(), {
         'id': CLUSTER_ID.get(),
         'name': CLUSTER_ID.get(),
         'type': 'direct',
         'interface': 'all',
-        'server_host': HIVE_SERVER_HOST.get()
+        'server_host': 'all'
         }
       )
     )
 
   # Get additional remote multi clusters
-  cluster_config = CLUSTERS.get()
   clusters.extend([
     (i, {
       'id': i,
@@ -1635,7 +1633,7 @@ def get_clusters(user):
       'type': cluster_config[i].TYPE.get(),
       'interface': cluster_config[i].INTERFACE.get() or 'hive',
       'server_host': cluster_config[i].SERVER_HOST.get()
-    }) for i in cluster_config if cluster_config[i].NAME.get() != 'default'
+    }) for i in cluster_config if i != 'Default'
   ])
 
   return OrderedDict(clusters)

+ 11 - 2
desktop/core/src/desktop/models.py

@@ -50,7 +50,7 @@ from notebook.conf import SHOW_NOTEBOOKS, get_ordered_interpreters
 
 from desktop import appmanager
 from desktop.conf import get_clusters, CLUSTER_ID, IS_MULTICLUSTER_ONLY,\
-  IS_EMBEDDED
+  IS_EMBEDDED, IS_K8_ONLY
 from desktop.lib.i18n import force_unicode
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.paths import get_run_root
@@ -1917,7 +1917,16 @@ class Cluster():
   def __init__(self, user):
     self.user = user
     self.clusters = get_clusters(user)
-    self.data = self.clusters['Altus' if IS_MULTICLUSTER_ONLY.get() else CLUSTER_ID.get()]
+
+    if len(self.clusters) == 1:
+      self.data = self.clusters.values()[0]
+    elif IS_K8_ONLY.get():
+      self.data = self.clusters['AltusV2']
+      self.data['type'] = 'altus' # To show simplified UI
+    elif IS_MULTICLUSTER_ONLY.get():
+      self.data = self.clusters['Altus']
+    else:
+      self.data = self.clusters[CLUSTER_ID.get()]
 
   def get_type(self):
     return self.data['type']

+ 3 - 0
desktop/libs/notebook/src/notebook/connectors/altus.py

@@ -50,6 +50,9 @@ def _exec(service, command, parameters=None):
   else:
     hostname = ALTUS.HOSTNAME.get()
 
+  if not ALTUS.AUTH_KEY_ID.get() or not ALTUS.AUTH_KEY_SECRET.get():
+    raise PopupException('Altus API is not configured.')
+
   try:
     api = ApiLib(service, hostname, ALTUS.AUTH_KEY_ID.get(), ALTUS.AUTH_KEY_SECRET.get().replace('\\n', '\n'))
     LOG.debug('%s : %s' % (command, parameters))