Browse Source

HUE-8758 [multi] Convert has_multi_cluster to current cluster having computes

Romain 6 years ago
parent
commit
529091c170

+ 3 - 3
apps/oozie/src/oozie/views/editor2.py

@@ -24,14 +24,14 @@ from django.forms.formsets import formset_factory
 from django.shortcuts import redirect
 from django.utils.translation import ugettext as _
 
-from desktop.conf import USE_NEW_EDITOR, IS_MULTICLUSTER_ONLY, has_multi_cluster
+from desktop.conf import USE_NEW_EDITOR, IS_MULTICLUSTER_ONLY
 from desktop.lib import django_mako
 from desktop.lib.django_util import JsonResponse, render
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_str, force_unicode
 from desktop.lib.rest.http_client import RestException
 from desktop.lib.json_utils import JSONEncoderForHTML
-from desktop.models import Document, Document2
+from desktop.models import Document, Document2, get_cluster_config
 
 from liboozie.credentials import Credentials
 from liboozie.oozie_api import get_oozie
@@ -721,7 +721,7 @@ def submit_coordinator(request, doc_id):
 def _submit_coordinator(request, coordinator, mapping):
   try:
     wf = coordinator.workflow
-    if IS_MULTICLUSTER_ONLY.get() and has_multi_cluster():
+    if IS_MULTICLUSTER_ONLY.get() and get_cluster_config(request.user)['has_computes']:
       mapping['auto-cluster'] = {
         u'additionalClusterResourceTags': [],
         u'automaticTerminationCondition': u'EMPTY_JOB_QUEUE', #'u'NONE',

+ 2 - 4
desktop/core/src/desktop/conf.py

@@ -1761,14 +1761,12 @@ def get_clusters(user):
   return OrderedDict(clusters)
 
 
-# Deprecated
-def has_multi_cluster():
-  return bool(CLUSTERS.get()) and False
-
 def has_multi_clusters():
+  '''If Hue is configured to talk to more than one completely independent clusters'''
   return len(CLUSTERS.get()) > 1
 
 def has_connectors():
+  '''When the connector feature is turned on'''
   return len(CONNECTORS.get()) >= 1
 
 

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

@@ -1571,7 +1571,6 @@ class ClusterConfig():
     self.apps = appmanager.get_apps_dict(self.user) if apps is None else apps
     self.cluster_type = cluster_type
 
-
   def refreshConfig(self):
     # TODO: reload "some ini sections"
     pass
@@ -1598,7 +1597,8 @@ class ClusterConfig():
         ] if app is not None
       ],
       'default_sql_interpreter': default_sql_interpreter,
-      'cluster_type': self.cluster_type
+      'cluster_type': self.cluster_type,
+      'has_computes': self.cluster_type in ['altus', 'snowball'] # or any grouped engine connectors
     }
 
 

+ 4 - 2
desktop/core/src/desktop/templates/global_js_constants.mako

@@ -19,7 +19,7 @@
 
   from desktop import conf
   from desktop.conf import IS_EMBEDDED, IS_K8S_ONLY, IS_MULTICLUSTER_ONLY, USE_NEW_SIDE_PANELS, VCS
-  from desktop.models import hue_version, _get_apps
+  from desktop.models import hue_version, _get_apps, get_cluster_config
 
   from beeswax.conf import LIST_PARTITIONS_LIMIT
   from dashboard.conf import HAS_SQL_ENABLED
@@ -57,8 +57,10 @@
   window.KNOX_BASE_PATH = window._KNOX_BASE_PATH.indexOf('KNOX_BASE_PATH_KNOX') < 0 ? window._KNOX_BASE_PATH_KNOX : '';
   window.KNOX_BASE_URL = window._KNOX_BASE_URL.indexOf('KNOX_BASE_URL') < 0 ? window._KNOX_BASE_URL : '';
 
+
   window.HAS_GIT = ${ len(VCS.keys()) } > 0;
-  window.HAS_MULTI_CLUSTER = '${ conf.has_multi_cluster() }' === 'True';
+  window.HAS_MULTI_CLUSTER = '${ get_cluster_config(user)['has_computes'] }' === 'True';
+
   window.HAS_SQL_DASHBOARD = '${ HAS_SQL_ENABLED.get() }' === 'True';
 
   window.DROPZONE_HOME_DIR = '${ user.get_home_directory() if not user.is_anonymous() else "" }';

+ 3 - 3
desktop/core/src/desktop/templates/hue.mako

@@ -18,10 +18,10 @@
   from django.utils.translation import ugettext as _
 
   from desktop import conf
-  from desktop.conf import IS_EMBEDDED, DEV_EMBEDDED, IS_MULTICLUSTER_ONLY, has_multi_cluster, has_multi_clusters
+  from desktop.conf import IS_EMBEDDED, DEV_EMBEDDED, IS_MULTICLUSTER_ONLY, has_multi_clusters
   from desktop.views import _ko, commonshare, login_modal
   from desktop.lib.i18n import smart_unicode
-  from desktop.models import PREFERENCE_IS_WELCOME_TOUR_SEEN, ANALYTIC_DB, hue_version
+  from desktop.models import PREFERENCE_IS_WELCOME_TOUR_SEEN, ANALYTIC_DB, hue_version, get_cluster_config
 
   from dashboard.conf import IS_ENABLED as IS_DASHBOARD_ENABLED
   from filebrowser.conf import SHOW_UPLOAD_BUTTON
@@ -193,7 +193,7 @@ ${ hueIcons.symbols() }
     <div class="navbar-inner top-nav">
       <div class="top-nav-left">
         % if not IS_EMBEDDED.get():
-          % if not (IS_MULTICLUSTER_ONLY.get() and has_multi_cluster()):
+          % if not (IS_MULTICLUSTER_ONLY.get() and get_cluster_config(user)['has_computes']):
           <a class="hamburger hamburger-hue pull-left" data-bind="toggle: leftNavVisible, css: { 'is-active': leftNavVisible }">
             <span class="hamburger-box"><span class="hamburger-inner"></span></span>
           </a>

+ 3 - 3
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -23,10 +23,11 @@ import uuid
 
 from django.utils.translation import ugettext as _
 
-from desktop.conf import has_multi_cluster, TASK_SERVER, has_connectors
+from desktop.conf import TASK_SERVER, has_connectors
 from desktop.lib import export_csvxls
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_unicode
+from desktop.models import get_cluster_config
 
 from notebook.conf import get_ordered_interpreters
 from notebook.sql_utils import get_current_statement
@@ -324,14 +325,13 @@ def get_api(request, snippet):
   interpreter = interpreter[0]
   interface = interpreter['interface']
 
-  # TODO: Multi cluster --> multi computes of a connector
   if has_connectors():
     cluster = {
       'connector': snippet['type'],
       'id': interpreter['type'],
     }
     cluster.update(interpreter['options'])
-  elif has_multi_cluster():
+  elif get_cluster_config(request.user)['has_computes']:
     cluster = json.loads(request.POST.get('cluster', '""')) # Via Catalog autocomplete API or Notebook create sessions
     if cluster == '""' or cluster == 'undefined':
       cluster = None