ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhew...@apache.org
Subject ambari git commit: AMBARI-16259 Retry of cluster install does not work (zhewang)
Date Wed, 04 May 2016 22:02:08 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 8a2a9fdc1 -> 3f59d882f


AMBARI-16259 Retry of cluster install does not work (zhewang)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3f59d882
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3f59d882
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3f59d882

Branch: refs/heads/trunk
Commit: 3f59d882f3291e643d9321861d63b00e77635045
Parents: 8a2a9fd
Author: Zhe (Joe) Wang <zhewang@apache.org>
Authored: Wed May 4 15:01:28 2016 -0700
Committer: Zhe (Joe) Wang <zhewang@apache.org>
Committed: Wed May 4 15:01:28 2016 -0700

----------------------------------------------------------------------
 .../app/controllers/wizard/step8_controller.js  | 66 +++++++++++++++++++-
 ambari-web/app/utils/ajax/ajax.js               |  9 +--
 .../test/controllers/wizard/step8_test.js       | 10 +--
 3 files changed, 74 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3f59d882/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 9cfc9d5..ee98bf5 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -170,6 +170,12 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
App.wiz
   clusterDeleteRequestsCompleted: 0,
 
   /**
+   * Number of existing repo_versions
+   * @type {number}
+   */
+  existingRepositoryVersions: 0,
+
+  /**
    * Indicates if all cluster delete requests are completed
    * @type {boolean}
    */
@@ -684,7 +690,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
App.wiz
       if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode'))
&& clusterNames.length) {
         self.deleteClusters(clusterNames);
       } else {
-        self.startDeploy();
+        self.getExistingVersions();
       }
     });
   },
@@ -756,7 +762,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
App.wiz
       if (this.get('clusterDeleteErrorViews.length')) {
         this.showDeleteClustersErrorPopup();
       } else {
-        this.startDeploy();
+        this.getExistingVersions();
       }
     }
   },
@@ -810,6 +816,62 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
App.wiz
   },
 
   /**
+   * Get existing repo_versions
+   * @method getExistingVersions
+   */
+  getExistingVersions: function () {
+    return App.ajax.send({
+      name: 'wizard.get_version_definitions',
+      sender: this,
+      success: 'getExistingVersionsSuccessCallback'
+    });
+  },
+
+  /**
+   * @param {Object} data
+   * @method getExistingVersionsSuccessCallback
+   */
+  getExistingVersionsSuccessCallback: function (data) {
+    if (this.get('content.controllerName') == 'installerController' && (!App.get('testMode'))
&& data.items.length) {
+      this.set('existingRepositoryVersions', data.items.length);
+      this.deleteExistingVersions(data.items);
+    } else {
+      this.startDeploy();
+    }
+  },
+
+  /**
+   * Delete existing repo_versions
+   * @param {Array} versions
+   * @method deleteExistingVersions
+   */
+  deleteExistingVersions: function (versions) {
+    versions.forEach(function (version) {
+      App.ajax.send({
+        name: 'wizard.delete_repository_versions',
+        sender: this,
+        data: {
+          id: version.VersionDefinition.id,
+          stackName: version.VersionDefinition.stack_name,
+          stackVersion: version.VersionDefinition.stack_version
+        },
+        success: 'deleteExistingVersionsSuccessCallback'
+      });
+    }, this);
+  },
+
+  /**
+   * Method to execute after successful version deletion
+   * @method deleteExistingVersionsSuccessCallback
+   */
+  deleteExistingVersionsSuccessCallback: function () {
+    this.decrementProperty('existingRepositoryVersions');
+    if (this.get('existingRepositoryVersions') === 0) {
+      this.startDeploy();
+    }
+  },
+
+  /**
    * updates kerberosDescriptorConfigs
    * @method updateKerberosDescriptor
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/3f59d882/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index dbe6891..866c454 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1937,11 +1937,12 @@ var urls = {
       }
     }
   },
-  'wizard.get_shown_version_definition': {
-    real: '/version_definitions?fields=VersionDefinition/stack_services&VersionDefinition/repository_version={repositoryVersion}&VersionDefinition/show_available=true'
+  'wizard.get_version_definitions': {
+    'real': '/version_definitions'
   },
-  'wizard.get_version_definition': {
-    real: '/version_definitions?fields=VersionDefinition/stack_services&VersionDefinition/repository_version={repositoryVersion}'
+  'wizard.delete_repository_versions': {
+    'real': '/stacks/{stackName}/versions/{stackVersion}/repository_versions/{id}',
+    'type': 'DELETE'
   },
   'wizard.service_components': {
     'real': '{stackUrl}/services?fields=StackServices/*,components/*,components/dependencies/Dependencies/scope,artifacts/Artifacts/artifact_name',

http://git-wip-us.apache.org/repos/asf/ambari/blob/3f59d882/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index b2c108a..ccd60f4 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1681,7 +1681,7 @@ describe('App.WizardStep8Controller', function () {
 
     beforeEach(function () {
       sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
-      sinon.stub(installerStep8Controller, 'startDeploy', Em.K);
+      sinon.stub(installerStep8Controller, 'getExistingVersions', Em.K);
       installerStep8Controller.setProperties({
         clusterDeleteRequestsCompleted: 0,
         clusterNames: ['c0', 'c1'],
@@ -1692,20 +1692,20 @@ describe('App.WizardStep8Controller', function () {
 
     afterEach(function () {
       installerStep8Controller.showDeleteClustersErrorPopup.restore();
-      installerStep8Controller.startDeploy.restore();
+      installerStep8Controller.getExistingVersions.restore();
     });
 
     describe('no failed requests', function () {
       it('before Delete Cluster request', function () {
         expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
         expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
-        expect(installerStep8Controller.startDeploy.called).to.be.false;
+        expect(installerStep8Controller.getExistingVersions.called).to.be.false;
       });
       it('after Delete Cluster request', function () {
         installerStep8Controller.deleteClusterSuccessCallback();
         expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
         expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
-        expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
+        expect(installerStep8Controller.getExistingVersions.calledOnce).to.be.true;
       });
     });
 
@@ -1713,7 +1713,7 @@ describe('App.WizardStep8Controller', function () {
       installerStep8Controller.deleteClusterErrorCallback({}, null, null, {});
       expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
       expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
-      expect(installerStep8Controller.startDeploy.called).to.be.false;
+      expect(installerStep8Controller.getExistingVersions.called).to.be.false;
     });
 
   });


Mime
View raw message