This is an automated email from the ASF dual-hosted git repository.

atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5a17cb6  AMBARI-22879 Ambari makes unrelated changes to zookeeper 
quorum config in all services when delete host action fails
5a17cb6 is described below

commit 5a17cb680e980035632647094a698963154533fa
Author: Andrii Tkach <[email protected]>
AuthorDate: Tue Jan 30 15:51:48 2018 +0200

    AMBARI-22879 Ambari makes unrelated changes to zookeeper quorum config in 
all services when delete host action fails
---
 ambari-web/app/controllers/main/host/details.js    | 62 +++++++++-------------
 .../test/controllers/main/host/details_test.js     |  7 ---
 2 files changed, 25 insertions(+), 44 deletions(-)

diff --git a/ambari-web/app/controllers/main/host/details.js 
b/ambari-web/app/controllers/main/host/details.js
index 9e05f2a..8486272 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -84,7 +84,9 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
   addDeleteComponentsMap: {
     'ZOOKEEPER_SERVER': {
       addPropertyName: 'addZooKeeperServer',
-      deletePropertyName: 'fromDeleteZkServer'
+      deletePropertyName: 'fromDeleteZkServer',
+      configsCallbackName: 'saveZkConfigs',
+      configTagsCallbackName: 'loadConfigsSuccessCallback'
     },
     'HIVE_METASTORE': {
       deletePropertyName: 'deleteHiveMetaStore',
@@ -557,11 +559,9 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
       }.property('controller.isReconfigureRequired', 
'controller.isConfigsLoadingInProgress', 'isChecked'),
       onPrimary: function () {
         this._super();
-        if (self.get('isReconfigureRequired')) {
-          self.applyConfigsCustomization();
-        }
         self._doDeleteHostComponent(componentName, function () {
-          if (self.get('isReconfigureRequired')) {
+          if (self.get('isReconfigureRequired') && 
self.get('_deletedHostComponentResult') === null) {
+            self.applyConfigsCustomization();
             self.saveConfigsBatch(self.get('groupedPropertiesToChange'), 
componentName);
             self.clearConfigsChanges();
           }
@@ -813,8 +813,8 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
       configTagsCallbackName,
       configsCallbackName;
     if (componentsMapItem) {
-      configTagsCallbackName = componentsMapItem.configTagsCallbackName || 
'loadConfigsSuccessCallback';
-      configsCallbackName = componentsMapItem.configsCallbackName || 
'saveZkConfigs';
+      configTagsCallbackName = componentsMapItem.configTagsCallbackName;
+      configsCallbackName = componentsMapItem.configsCallbackName;
     }
     if (hasHostsSelect) {
       if (this.get('isReconfigureRequired')) {
@@ -1722,9 +1722,9 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
       name: 'config.tags',
       sender: this,
       data: {
-        callback: configsCallback || 'saveZkConfigs'
+        callback: configsCallback
       },
-      success: configTagsCallback || 'loadConfigsSuccessCallback',
+      success: configTagsCallback,
       error: 'onLoadConfigsErrorCallback'
     });
     this.trackRequest(request);
@@ -1754,7 +1754,7 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
         data: {
           urlParams: urlParams.join('|')
         },
-        success: params.callback || 'saveZkConfigs'
+        success: params.callback
       });
       this.trackRequest(request);
       return true;
@@ -2767,40 +2767,32 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
         templateName: require('templates/main/host/details/doDeleteHostPopup')
       }),
       onPrimary: function () {
-        var popup = this;
-        var completeCallback = function () {
-          var remainingHosts = 
App.db.getSelectedHosts('mainHostController').removeObject(self.get('content.hostName'));
-          App.db.setSelectedHosts(remainingHosts);
-          popup.hide();
-        };
-        self.doDeleteHost(completeCallback);
+        this.hide();
+        self.doDeleteHost();
       }
     });
   },
 
   /**
    * send DELETE calls to components of host and after delete host itself
-   * @param completeCallback
    * @method doDeleteHost
    */
-  doDeleteHost: function (completeCallback) {
+  doDeleteHost: function () {
     this.set('fromDeleteHost', true);
     var allComponents = this.get('content.hostComponents');
     var deleteError = null;
     var dfd = $.Deferred();
+    var length = allComponents.get('length');
     var self = this;
 
-    if (allComponents.get('length') > 0) {
+    if (length > 0) {
       allComponents.forEach(function (component, index) {
-        var length = allComponents.get('length');
-        if (!deleteError) {
-          this._doDeleteHostComponent(component.get('componentName'), function 
() {
-            deleteError = self.get('_deletedHostComponentResult');
-            if (index == length - 1) {
-              dfd.resolve();
-            }
-          });
-        }
+        this._doDeleteHostComponent(component.get('componentName'), function 
() {
+          deleteError = deleteError ? deleteError : 
self.get('_deletedHostComponentResult');
+          if (index === length - 1) {
+            dfd.resolve();
+          }
+        });
       }, this);
     } else {
       dfd.resolve();
@@ -2813,14 +2805,12 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
           data: {
             hostName: self.get('content.hostName')
           },
-          callback: completeCallback,
           success: 'deleteHostSuccessCallback',
           error: 'deleteHostErrorCallback',
           showLoadingPopup: true
         });
       }
       else {
-        completeCallback();
         deleteError.xhr.responseText = "{\"message\": \"" + 
deleteError.xhr.statusText + "\"}";
         App.ajax.defaultErrorHandler(deleteError.xhr, deleteError.url, 
deleteError.type, deleteError.xhr.status);
       }
@@ -2830,17 +2820,15 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
     App.router.get('updateController').updateHost(function () {
       App.router.transitionTo('hosts.index');
     });
-    if (!!(requestBody && requestBody.hostName))
+    if (!!(requestBody && requestBody.hostName)) {
+      var remainingHosts = 
App.db.getSelectedHosts('mainHostController').removeObject(requestBody.hostName);
+      App.db.setSelectedHosts('mainHostController', remainingHosts);
       App.hostsMapper.deleteRecord(App.Host.find().findProperty('hostName', 
requestBody.hostName));
+    }
     App.router.get('clusterController').getAllHostNames();
   },
   deleteHostErrorCallback: function (xhr, textStatus, errorThrown, opt) {
     xhr.responseText = "{\"message\": \"" + xhr.statusText + "\"}";
-    var self = this;
-    var callback = function () {
-      self.loadConfigs();
-    };
-    self.isServiceMetricsLoaded(callback);
     App.ajax.defaultErrorHandler(xhr, opt.url, 'DELETE', xhr.status);
   },
 
diff --git a/ambari-web/test/controllers/main/host/details_test.js 
b/ambari-web/test/controllers/main/host/details_test.js
index e9490fb..10840db 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -3034,9 +3034,7 @@ describe('App.MainHostDetailsController', function () {
   describe("#deleteHostErrorCallback", function () {
 
     beforeEach(function () {
-      sinon.stub(controller, 'loadConfigs', Em.K);
       sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
-      sinon.stub(controller, 'isServiceMetricsLoaded', Em.clb);
       controller.deleteHostErrorCallback({
         status: 'status',
         statusText: "statusText"
@@ -3045,13 +3043,8 @@ describe('App.MainHostDetailsController', function () {
 
     afterEach(function () {
       App.ajax.defaultErrorHandler.restore();
-      controller.loadConfigs.restore();
-      controller.isServiceMetricsLoaded.restore();
     });
 
-    it('loadConfigs is called once', function () {
-      expect(controller.loadConfigs.calledOnce).to.be.true;
-    });
     it('defaultErrorHandler is called once', function () {
       expect(App.ajax.defaultErrorHandler.calledOnce).to.be.true;
     });

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to