Browse Source

[taskserver] Disable schedule tasks tab in job browser based on task_server_v2 configs (#3743)

Co-authored-by: Athithyaa Selvam <aselvam@cloudera.com>
Athithyaa Selvam 1 year ago
parent
commit
dc02b1bc73

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

@@ -52,7 +52,7 @@ from desktop.conf import (
   HUE_IMAGE_VERSION,
   IS_MULTICLUSTER_ONLY,
   RAZ,
-  TASK_SERVER_V2,
+  TASK_SERVER,
   get_clusters,
   has_connectors,
 )
@@ -2200,7 +2200,7 @@ class ClusterConfig(object):
         }
       ])
 
-    if TASK_SERVER_V2.BEAT_ENABLED.get():
+    if TASK_SERVER.BEAT_ENABLED.get():
       interpreters.append({
           'type': 'celery-beat',
           'displayName': _('Scheduled Tasks'),

+ 1 - 1
desktop/libs/notebook/src/notebook/api.py

@@ -26,7 +26,7 @@ from django.urls import reverse
 from django.views.decorators.http import require_GET, require_POST
 
 from azure.abfs.__init__ import abfspath
-from desktop.conf import ENABLE_CONNECTORS, TASK_SERVER_V2
+from desktop.conf import ENABLE_CONNECTORS
 from desktop.lib.django_util import JsonResponse
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_str

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

@@ -27,7 +27,7 @@ from django.utils.encoding import smart_str
 
 from beeswax.common import find_compute, is_compute
 from desktop.auth.backend import is_admin
-from desktop.conf import TASK_SERVER_V2, 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
@@ -425,7 +425,7 @@ def patch_snippet_for_connector(snippet, user=None):
 def get_api(request, snippet):
   from notebook.connectors.oozie_batch import OozieApi
 
-  if snippet.get('wasBatchExecuted') and not TASK_SERVER_V2.ENABLED.get():
+  if snippet.get('wasBatchExecuted') and not TASK_SERVER.ENABLED.get():
     return OozieApi(user=request.user, request=request)
 
   if snippet.get('type') == 'report':

+ 1 - 1
desktop/libs/notebook/src/notebook/models.py

@@ -30,7 +30,7 @@ from django.db.models import Count
 from django.db.models.functions import Trunc
 from django.utils.html import escape
 
-from desktop.conf import TASK_SERVER_V2, has_connectors
+from desktop.conf import has_connectors
 from desktop.lib.connectors.models import _get_installed_connectors
 from desktop.lib.i18n import smart_unicode
 from desktop.lib.paths import SAFE_CHARACTERS_URI

+ 6 - 6
desktop/libs/notebook/src/notebook/tasks.py

@@ -36,7 +36,7 @@ from django.http import FileResponse, HttpRequest
 from beeswax.data_export import DataAdapter
 from desktop.auth.backend import rewrite_user
 from desktop.celery import app
-from desktop.conf import ENABLE_HUE_5, TASK_SERVER_V2
+from desktop.conf import ENABLE_HUE_5, TASK_SERVER
 from desktop.lib import export_csvxls, fsmanager
 from desktop.models import Document2
 from desktop.settings import CACHES_CELERY_KEY, CACHES_CELERY_QUERY_RESULT_KEY
@@ -68,7 +68,7 @@ STATE_MAP = {
   states.REJECTED: 'rejected',
   states.IGNORED: 'ignored'
 }
-storage_info = json.loads(TASK_SERVER_V2.RESULT_STORAGE.get())
+storage_info = json.loads(TASK_SERVER.RESULT_STORAGE.get())
 storage = get_storage_class(storage_info.get('backend'))(**storage_info.get('properties', {}))
 
 
@@ -130,7 +130,7 @@ def download_to_file(notebook, snippet, file_format='csv', max_rows=-1, **kwargs
       for chunk in response:
         f.write(chunk.encode('utf-8'))
 
-    if TASK_SERVER_V2.RESULT_CACHE.get():
+    if TASK_SERVER.RESULT_CACHE.get():
       with storage.open(result_key, 'rb') as store:
         with codecs.getreader('utf-8')(store) as text_file:
           delimiter = ',' if sys.version_info[0] > 2 else ','.encode('utf-8')
@@ -234,7 +234,7 @@ def _patch_status(notebook):
 def execute(*args, **kwargs):
   notebook = args[0]
   snippet = args[1]
-  kwargs['max_rows'] = TASK_SERVER_V2.FETCH_RESULT_LIMIT.get()
+  kwargs['max_rows'] = TASK_SERVER.FETCH_RESULT_LIMIT.get()
   _patch_status(notebook)
 
   task = download_to_file.apply_async(args=args, kwargs=kwargs, task_id=notebook['uuid'])
@@ -283,7 +283,7 @@ def get_log(notebook, snippet, startFrom=None, size=None, postdict=None, user_id
   elif state in states.EXCEPTION_STATES:
     return ''
 
-  if TASK_SERVER_V2.RESULT_CACHE.get():
+  if TASK_SERVER.RESULT_CACHE.get():
     return ''
   else:
     if not startFrom:
@@ -395,7 +395,7 @@ def fetch_result(notebook, snippet, rows, start_over, **kwargs):
 def _get_data(task_id):
   result_key = _result_key(task_id)
 
-  if TASK_SERVER_V2.RESULT_CACHE.get():
+  if TASK_SERVER.RESULT_CACHE.get():
     csv_reader = caches[CACHES_CELERY_QUERY_RESULT_KEY].get(result_key)  # TODO check if expired
     if csv_reader is None:
       raise QueryError('Cached results %s not found.' % result_key)