Pārlūkot izejas kodu

HUE-8500 [jb] Support terminating a remove cluster from the interface

Romain Rigaux 7 gadi atpakaļ
vecāks
revīzija
0012358e32

+ 23 - 7
apps/jobbrowser/src/jobbrowser/apis/data_eng_api.py

@@ -42,12 +42,13 @@ class DataEngClusterApi(Api):
         'name': '%(clusterName)s' % app,
         'status': app['status'],
         'apiStatus': self._api_status(app['status']),
-        'type': '%(serviceType)s %(workersGroupSize)s %(instanceType)s %(cdhVersion)s' % app,
+        'type': 'Altus %(serviceType)s %(workersGroupSize)s %(instanceType)s %(cdhVersion)s' % app,
         'user': app['clusterName'].split('-', 1)[0],
         'progress': 100,
         'queue': 'group',
         'duration': 1,
-        'submitted': app['creationDate']
+        'submitted': app['creationDate'],
+        'canWrite': True
       } for app in jobs['clusters']],
       'total': len(jobs)
     }
@@ -58,7 +59,20 @@ class DataEngClusterApi(Api):
 
 
   def action(self, appid, action):
-    return {}
+    message = {'message': '', 'status': 0}
+
+    if action.get('action') == 'kill':
+      api = DataEngApi(self.user)
+
+      for _id in appid:
+        result = api.delete_cluster(_id)
+        if result.get('error'):
+          message['message'] = result.get('error')
+          message['status'] = -1
+        elif result.get('contents') and message.get('status') != -1:
+          message['message'] = result.get('contents')
+
+    return message;
 
 
   def logs(self, appid, app_type, log_name=None, is_embeddable=False):
@@ -69,9 +83,9 @@ class DataEngClusterApi(Api):
     return {}
 
   def _api_status(self, status):
-    if status in ['CREATING', 'CREATED', 'TERMINATING']:
+    if status in ['CREATING', 'CREATED']:
       return 'RUNNING'
-    elif status in ['ARCHIVING', 'COMPLETED']:
+    elif status in ['ARCHIVING', 'COMPLETED', 'TERMINATING']:
       return 'SUCCEEDED'
     else:
       return 'FAILED' # KILLED and FAILED
@@ -102,11 +116,12 @@ class DataEngJobApi(Api):
         'name': app['creationDate'],
         'status': app['status'],
         'apiStatus': self._api_status(app['status']),
-        'type': app['jobType'],
+        'type': 'Altus %(jobType)s' % app,
         'user': '',
         'progress': 100,
         'duration': 10 * 3600,
-        'submitted': app['creationDate']
+        'submitted': app['creationDate'],
+        'canWrite': True
       } for app in jobs['jobs']],
       'total': len(jobs)
     }
@@ -125,6 +140,7 @@ class DataEngJobApi(Api):
         'duration': 10 * 3600,
         'submitted': job['creationDate'],
         'type': 'dataeng-job-%s' % job['jobType'],
+        'canWrite': True
     }
 
     common['properties'] = {

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

@@ -2061,7 +2061,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       self.rerunModalContent = ko.observable('');
 
       self.hasKill = ko.pureComputed(function() {
-        return ['MAPREDUCE', 'SPARK', 'workflow', 'schedule', 'bundle', 'QUERY'].indexOf(self.type()) != -1;
+        return ['MAPREDUCE', 'SPARK', 'workflow', 'schedule', 'bundle', 'QUERY'].indexOf(self.type()) != -1 || self.type().indexOf('Altus') != -1;
       });
       self.killEnabled = ko.pureComputed(function() {
         // Impala can kill queries that are finished, but not yet terminated
@@ -2423,7 +2423,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       self.selectedJobs = ko.observableArray();
 
       self.hasKill = ko.pureComputed(function() {
-        return ['jobs', 'workflows', 'schedules', 'bundles', 'queries'].indexOf(vm.interface()) != -1 && !self.isCoordinator();
+        return ['jobs', 'workflows', 'schedules', 'bundles', 'queries', 'dataeng-jobs', 'dataeng-clusters'].indexOf(vm.interface()) != -1 && !self.isCoordinator();
       });
       self.killEnabled = ko.pureComputed(function() {
         return self.hasKill() && self.selectedJobs().length > 0 && $.grep(self.selectedJobs(), function(job) {

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

@@ -214,8 +214,8 @@ class DataEngApi():
 
     return _exec('dataeng', 'createAWSCluster', params)
 
-  def delete_cluster(self):
-    return _exec('dataeng', 'deleteCluster')
+  def delete_cluster(self, cluster_id):
+    return _exec('dataeng', 'deleteCluster', {'clusterName': cluster_id})
 
   def describe_clusters(self):
     return _exec('dataeng', 'describeCluster')