Repository: ambari Updated Branches: refs/heads/trunk 4c0cb0559 -> 987373628
AMBARI-13594.Express Upgrade: UI - Disallow RU in HDP 2.1->2.3 since no upgrade pack supports it.(xiwang) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/98737362 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/98737362 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/98737362 Branch: refs/heads/trunk Commit: 9873736281e3adf123dd96ac3520245c7ed44d1d Parents: 4c0cb05 Author: Xi Wang <xiw...@apache.org> Authored: Tue Oct 27 17:57:11 2015 -0700 Committer: Xi Wang <xiw...@apache.org> Committed: Wed Oct 28 10:56:30 2015 -0700 ---------------------------------------------------------------------- .../stack_versions/supported_upgrade_types.json | 18 +++++++++++ .../main/admin/stack_and_upgrade_controller.js | 32 +++++++++++++++++++- ambari-web/app/utils/ajax/ajax.js | 5 +++ .../admin/stack_and_upgrade_controller_test.js | 8 +++++ 4 files changed, 62 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/98737362/ambari-web/app/assets/data/stack_versions/supported_upgrade_types.json ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/data/stack_versions/supported_upgrade_types.json b/ambari-web/app/assets/data/stack_versions/supported_upgrade_types.json new file mode 100644 index 0000000..eb4ed59 --- /dev/null +++ b/ambari-web/app/assets/data/stack_versions/supported_upgrade_types.json @@ -0,0 +1,18 @@ +{ + "href" : "http://c6401.ambari.apache.org:8080/api/v1/stacks/HDP/versions/2.3/compatible_repository_versions?CompatibleRepositoryVersions/repository_version=2.3.4.0-3074", + "items" : [ + { + "href" : "http://c6401.ambari.apache.org:8080/api/v1/stacks/HDP/versions/2.3/compatible_repository_versions/2", + "CompatibleRepositoryVersions" : { + "id" : 2, + "repository_version" : "2.3.4.0-3074", + "stack_name" : "HDP", + "stack_version" : "2.3", + "upgrade_types" : [ + "ROLLING", + "NON_ROLLING" + ] + } + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/98737362/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js index a8a9853..9a1ac80 100644 --- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js +++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js @@ -605,7 +605,13 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, upgradeOptions: function (isInUpgradeWizard, version) { var self = this; if (!isInUpgradeWizard) { - this.runUpgradeMethodChecks(version); + this.getSupportedUpgradeTypes(Ember.Object.create({ + stackName: App.get('currentStackVersion').split('-')[0], + stackVersion: App.get('currentStackVersion').split('-')[1], + toVersion: version.get('repositoryVersion') + })).done(function(){ + self.runUpgradeMethodChecks(version); + }); } return App.ModalPopup.show({ @@ -768,6 +774,30 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, }, /** + * send request to get available upgrade tye names + */ + getSupportedUpgradeTypes: function(data) { + return App.ajax.send({ + name: "admin.upgrade.get_supported_upgradeTypes", + sender: this, + data: data, + success: "getSupportedUpgradeTypesSuccess", + error: "getSupportedUpgradeTypesError" + }); + }, + + /** + * success callback of <code>getSupportedUpgradeTypes()</code> + * @param data {object} + */ + getSupportedUpgradeTypesSuccess: function (data) { + var supportedUpgradeTypes = data.items[0] && data.items[0].CompatibleRepositoryVersions.upgrade_types; + this.get('upgradeMethods').forEach(function (method) { + method.set('allowed', supportedUpgradeTypes && !!supportedUpgradeTypes.contains(method.get('type'))); + }); + }, + + /** * success callback of <code>runPreUpgradeCheckOnly()</code> * Show a message how many fails/warnings/passed * on clicking that message a popup window show up http://git-wip-us.apache.org/repos/asf/ambari/blob/98737362/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 30daace..e862ac4 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -1729,6 +1729,11 @@ var urls = { 'mock': '/data/stack_versions/pre_upgrade_check.json' }, + 'admin.upgrade.get_supported_upgradeTypes': { + 'real': '/stacks/{stackName}/versions/{stackVersion}/compatible_repository_versions?CompatibleRepositoryVersions/repository_version={toVersion}', + 'mock': '/data/stack_versions/supported_upgrade_types.json' + }, + 'admin.kerberos_security.checks': { //TODO when api will be known 'real': '', http://git-wip-us.apache.org/repos/asf/ambari/blob/98737362/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js index 2c15790..67fc368 100644 --- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js +++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js @@ -768,15 +768,20 @@ describe('App.MainAdminStackAndUpgradeController', function() { before(function () { sinon.spy(App, 'ModalPopup'); sinon.spy(App, 'showConfirmationFeedBackPopup'); + this.mock = sinon.stub(controller, 'getSupportedUpgradeTypes'); sinon.stub(controller, 'runPreUpgradeCheck', Em.K); }); after(function () { App.ModalPopup.restore(); App.showConfirmationFeedBackPopup.restore(); controller.runPreUpgradeCheck.restore(); + this.mock.restore(); }); it("show confirmation popup", function() { var version = Em.Object.create({displayName: 'HDP-2.2'}); + this.mock.returns({ + done: function(callback) {callback([1]);} + }); controller.upgradeMethods = [ Em.Object.create({ displayName: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.RU.title'), @@ -805,6 +810,9 @@ describe('App.MainAdminStackAndUpgradeController', function() { }); it("NOT show confirmation popup on Downgrade", function() { var version = Em.Object.create({displayName: 'HDP-2.2'}); + this.mock.returns({ + done: function(callback) {callback([1]);} + }); controller.set('isDowngrade', true); var popup = controller.upgradeOptions(false, version); expect(App.ModalPopup.calledOnce).to.be.false;