Explorar o código

AMBARI-15532 ambari-web allows to delete a service that has running processes. (ababiichuk)

ababiichuk %!s(int64=9) %!d(string=hai) anos
pai
achega
751e69209b

+ 2 - 4
ambari-web/app/controllers/main/service/item.js

@@ -1082,11 +1082,9 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
    * @param serviceNames
    */
   allowUninstallServices: function(serviceNames) {
-    return !App.Service.find().filter(function (service) {
+    return App.Service.find().filter(function (service) {
       return serviceNames.contains(service.get('serviceName'));
-    }).mapProperty('workStatus').some(function (workStatus) {
-      return !App.Service.allowUninstallStates.contains(workStatus);
-    });
+    }).everyProperty('allowToDelete');
   },
 
   /**

+ 1 - 1
ambari-web/app/messages.js

@@ -1742,7 +1742,7 @@ Em.I18n.translations = {
   'services.service.delete.configVersionNote.plural': 'Update configs after {0} have been removed',
   'services.service.delete.lastService.popup.body': 'The <b>{0}</b> service can\'t be deleted, at least one service must be installed.',
   'services.service.delete.popup.dependentServices': 'Prior to deleting <b>{0}</b>, you must delete the following dependent services:',
-  'services.service.delete.popup.mustBeStopped': 'Prior to deleting <b>{0}</b>, you must stop the service.',
+  'services.service.delete.popup.mustBeStopped': 'Prior to deleting <b>{0}</b>, you must stop the service and each slave and master component.',
   'services.service.delete.popup.mustBeStopped.dependent': ' Along with dependent service <b>{0}</b>.',
   'services.service.delete.popup.warning': 'The <b>{0} service will be removed from Ambari and all configurations' +
   ' and configuration history will be lost.</b>',

+ 9 - 0
ambari-web/app/models/client_component.js

@@ -29,6 +29,15 @@ App.ClientComponent = DS.Model.extend({
   stackInfo: DS.belongsTo('App.StackServiceComponent'),
   hostNames: DS.attr('array'),
 
+  /**
+   * Defines if all components are in 'INSTALLED' state
+   *
+   * @type {boolean}
+   */
+  allStopped: function() {
+    return this.get('installedCount') === this.get('totalCount');
+  }.property('installedCount', 'totalCount'),
+
   summaryLabelClassName:function(){
     return 'label_for_'+this.get('componentName').toLowerCase();
   }.property('componentName'),

+ 12 - 0
ambari-web/app/models/service.js

@@ -40,6 +40,18 @@ App.Service = DS.Model.extend({
   slaveComponents: DS.hasMany('App.SlaveComponent'),
   masterComponents: DS.hasMany('App.MasterComponent'),
 
+  /**
+   * Check master/slave component state of service
+   * and general services state to define if it can be removed
+   *
+   * @type {boolean}
+   */
+  allowToDelete: function() {
+    return App.Service.allowUninstallStates.contains(this.get('workStatus'))
+      && this.get('slaveComponents').everyProperty('allStopped')
+      && this.get('masterComponents').everyProperty('allStopped');
+  }.property('slaveComponents.@each.allStopped', 'masterComponents.@each.allStopped', 'workStatus'),
+
   /**
    * @type {bool}
    */