Repository: ambari Updated Branches: refs/heads/trunk b2cc1c929 -> 8690cfdb4
AMBARI-11340. FE: Add Prerequisite Check for Conflicting Configs (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8690cfdb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8690cfdb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8690cfdb Branch: refs/heads/trunk Commit: 8690cfdb4ab8e97c84d4c0a4e4296277617355b7 Parents: b2cc1c9 Author: Aleksandr Kovalenko <[email protected]> Authored: Fri May 22 17:13:21 2015 +0300 Committer: Aleksandr Kovalenko <[email protected]> Committed: Mon May 25 12:51:28 2015 +0300 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../main/admin/stack_and_upgrade_controller.js | 7 ++ ambari-web/app/messages.js | 8 ++ ambari-web/app/styles/common.less | 26 ++++++ .../upgrade_configs_merge_popup.hbs | 45 ++++++++++ ambari-web/app/views.js | 1 + .../modal_popups/upgrade_configs_merge_popup.js | 63 ++++++++++++++ .../admin/stack_and_upgrade_controller_test.js | 85 ++++++++++++------ .../upgrade_configs_merge_popup_test.js | 91 ++++++++++++++++++++ 9 files changed, 302 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index e364b45..3a09f10 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -189,6 +189,7 @@ var files = ['test/init_model_test', 'test/views/common/progress_bar_view_test', 'test/views/common/widget/graph_widget_view_test', 'test/views/common/modal_popups/hosts_table_list_popup_test', + 'test/views/common/modal_popups/upgrade_configs_merge_popup_test', 'test/views/main/admin_test', 'test/views/main/dashboard_test', 'test/views/main/menu_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/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 6a1497f..223685b 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 @@ -459,6 +459,13 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, var title = Em.I18n.t('popup.clusterCheck.Upgrade.title'); var alert = Em.I18n.t('popup.clusterCheck.Upgrade.alert'); App.showClusterCheckPopup(data, header, title, alert); + } else if (data.items.someProperty('UpgradeChecks.status', "WARNING") && data.items.someProperty('UpgradeChecks.id', "CONFIG_MERGE")) { + var self = this, + configsMergeCheckData = data.items.findProperty('UpgradeChecks.id', "CONFIG_MERGE").UpgradeChecks.failed_detail; + this.set('requestInProgress', false); + App.showUpgradeConfigsMergePopup(configsMergeCheckData, params.label, function () { + self.upgrade(params); + }); } else { this.upgrade(params); } http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 13a7d44..d49169d 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -340,6 +340,14 @@ Em.I18n.translations = { 'popup.clusterCheck.Upgrade.header': 'Upgrade to {0}', 'popup.clusterCheck.Upgrade.title': 'Upgrade Requirements Not Met', 'popup.clusterCheck.Upgrade.alert': 'You must meet the following requirements before you can proceed with rolling upgrade.', + 'popup.clusterCheck.Upgrade.configsMerge.subtitle': 'As part of Rolling Upgrade, the following configuration properties will be automatically set to the resulting values shown.', + 'popup.clusterCheck.Upgrade.configsMerge.configType': 'Config Type', + 'popup.clusterCheck.Upgrade.configsMerge.propertyName': 'Property Name', + 'popup.clusterCheck.Upgrade.configsMerge.currentValue': 'Current Value', + 'popup.clusterCheck.Upgrade.configsMerge.recommendedValue': 'Recommended Value', + 'popup.clusterCheck.Upgrade.configsMerge.resultingValue': 'Resulting Value', + 'popup.clusterCheck.Upgrade.configsMerge.deprecated': 'Property is deprecated', + 'popup.clusterCheck.Upgrade.configsMerge.willBeRemoved': 'Will be removed', 'popup.clusterCheck.Security.header': 'Enable Security', 'popup.clusterCheck.Security.title': 'Security Requirements Not Met', 'popup.clusterCheck.Security.alert': 'You must meet the following requirements before you can enable security.', http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/ambari-web/app/styles/common.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/common.less b/ambari-web/app/styles/common.less index 1b49e5e..1a8bbda 100644 --- a/ambari-web/app/styles/common.less +++ b/ambari-web/app/styles/common.less @@ -329,4 +329,30 @@ padding: 0; } } +} + +.configs-merge-warnings { + .modal { + width: 950px; + margin-left: -475px; + } + .icon-info-sign { + color: @blue; + } + .configs-table { + table-layout: fixed; + font-size: 0.95em; + td { + word-wrap: break-word; + &.no-value { + font-style: italic; + } + } + td:first-child, td:first-child + td, th:first-child, th:first-child + th { + width: 12.5%; + } + td:first-child + td + td, td:first-child + td + td + td, td:first-child + td + td + td + td, th:first-child + th + th, th:first-child + th + th + th, th:first-child + th + th + th + th { + width: 25%; + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/ambari-web/app/templates/common/modal_popups/upgrade_configs_merge_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/upgrade_configs_merge_popup.hbs b/ambari-web/app/templates/common/modal_popups/upgrade_configs_merge_popup.hbs new file mode 100644 index 0000000..722e4c5 --- /dev/null +++ b/ambari-web/app/templates/common/modal_popups/upgrade_configs_merge_popup.hbs @@ -0,0 +1,45 @@ +{{! +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +}} + +<div> + <i class="icon-info-sign"></i> <span>{{t popup.clusterCheck.Upgrade.configsMerge.subtitle}}</span> +</div> +<div class="limited-height-2"> + <table class="configs-table table table-striped"> + <thead> + <tr> + <th>{{t popup.clusterCheck.Upgrade.configsMerge.configType}}</th> + <th>{{t popup.clusterCheck.Upgrade.configsMerge.propertyName}}</th> + <th>{{t popup.clusterCheck.Upgrade.configsMerge.currentValue}}</th> + <th><span class="recommended-value">{{t popup.clusterCheck.Upgrade.configsMerge.recommendedValue}}</span></th> + <th>{{t popup.clusterCheck.Upgrade.configsMerge.resultingValue}}</th> + </tr> + </thead> + <tbody> + {{#each view.configs}} + <tr> + <td>{{type}}</td> + <td>{{name}}</td> + <td>{{currentValue}}</td> + <td {{bindAttr class="isDeprecated:no-value"}}>{{recommendedValue}}</td> + <td {{bindAttr class="willBeRemoved:no-value"}}>{{resultingValue}}</td> + </tr> + {{/each}} + </tbody> + </table> +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index 607b693..a6557fc 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -34,6 +34,7 @@ require('views/common/modal_popups/cluster_check_popup'); require('views/common/modal_popups/invalid_KDC_popup'); require('views/common/modal_popups/dependent_configs_list_popup'); require('views/common/modal_popups/select_groups_popup'); +require('views/common/modal_popups/upgrade_configs_merge_popup'); require('views/common/editable_list'); require('views/common/rolling_restart_view'); require('views/common/select_custom_date_view'); http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/ambari-web/app/views/common/modal_popups/upgrade_configs_merge_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/upgrade_configs_merge_popup.js b/ambari-web/app/views/common/modal_popups/upgrade_configs_merge_popup.js new file mode 100644 index 0000000..68a1b2f --- /dev/null +++ b/ambari-web/app/views/common/modal_popups/upgrade_configs_merge_popup.js @@ -0,0 +1,63 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +/** + * Popup with configs merge warnings from Rolling Upgrade prerequisite checks + * @param conflicts + * @param version + * @param callback + * @returns {App.ModalPopup} + */ +App.showUpgradeConfigsMergePopup = function (conflicts, version, callback) { + var configs = conflicts.map(function (item) { + var isDeprecated = Em.isNone(item.new_stack_value), + willBeRemoved = Em.isNone(item.result_value); + return { + type: item.type, + name: item.property, + currentValue: item.current, + recommendedValue: isDeprecated ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.deprecated') : item.new_stack_value, + isDeprecated: isDeprecated, + resultingValue: willBeRemoved ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.willBeRemoved') : item.result_value, + willBeRemoved: willBeRemoved + }; + }); + return App.ModalPopup.show({ + classNames: ['configs-merge-warnings'], + primary: Em.I18n.t('common.proceedAnyway'), + secondary: Em.I18n.t('form.cancel'), + header: Em.I18n.t('popup.clusterCheck.Upgrade.header').format(version), + bodyClass: Em.View.extend({ + templateName: require('templates/common/modal_popups/upgrade_configs_merge_popup'), + configs: configs, + didInsertElement: function () { + App.tooltip($('.recommended-value'), { + title: version + }); + } + }), + onPrimary: function () { + if (callback) { + callback(); + } + this._super(); + } + }); +}; http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/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 d17268c..7041a38 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 @@ -252,41 +252,76 @@ describe('App.MainAdminStackAndUpgradeController', function() { }); describe("#runPreUpgradeCheckSuccess()", function () { - beforeEach(function () { - sinon.stub(App, 'showClusterCheckPopup', Em.K); - sinon.stub(controller, 'upgrade', Em.K); - }); - afterEach(function () { - App.showClusterCheckPopup.restore(); - controller.upgrade.restore(); - }); - it("shows popup", function () { - var check = { items: [{ - UpgradeChecks: { + var cases = [ + { + check: { "check": "Work-preserving RM/NM restart is enabled in YARN configs", "status": "FAIL", "reason": "FAIL", "failed_on": [], "check_type": "SERVICE" - } - }]}; - controller.runPreUpgradeCheckSuccess(check,null,{label: "name"}); - expect(controller.upgrade.called).to.be.false; - expect(App.showClusterCheckPopup.called).to.be.true; - }); - it("runs upgrade popup", function () { - var check = { items: [{ - UpgradeChecks: { + }, + showClusterCheckPopupCalledCount: 1, + showUpgradeConfigsMergePopupCalledCount: 0, + upgradeCalledCount: 0, + title: 'error popup is displayed is errors are present' + }, + { + check: { + "check": "Configuration Merge Check", + "status": "WARNING", + "reason": "Conflict", + "failed_on": [], + "failed_detail": [], + "check_type": "CLUSTER", + "id": "CONFIG_MERGE" + }, + showClusterCheckPopupCalledCount: 0, + showUpgradeConfigsMergePopupCalledCount: 1, + upgradeCalledCount: 0, + title: 'warnings popup is displayed is configs merge conflicts are present' + }, + { + check: { "check": "Work-preserving RM/NM restart is enabled in YARN configs", "status": "PASS", "reason": "OK", "failed_on": [], "check_type": "SERVICE" - } - }]}; - controller.runPreUpgradeCheckSuccess(check,null,{label: "name"}); - expect(controller.upgrade.called).to.be.true; - expect(App.showClusterCheckPopup.called).to.be.false; + }, + showClusterCheckPopupCalledCount: 0, + showUpgradeConfigsMergePopupCalledCount: 0, + upgradeCalledCount: 1, + title: 'upgrade is started if errors and configs merge conflicts are absent' + } + ]; + beforeEach(function () { + sinon.stub(App, 'showClusterCheckPopup', Em.K); + sinon.stub(App, 'showUpgradeConfigsMergePopup', Em.K); + sinon.stub(controller, 'upgrade', Em.K); + }); + afterEach(function () { + App.showClusterCheckPopup.restore(); + App.showUpgradeConfigsMergePopup.restore(); + controller.upgrade.restore(); + }); + cases.forEach(function (item) { + it(item.title, function () { + controller.runPreUpgradeCheckSuccess( + { + items: [ + { + UpgradeChecks: item.check + } + ] + }, null, { + label: 'name' + } + ); + expect(controller.upgrade.callCount).to.equal(item.upgradeCalledCount); + expect(App.showClusterCheckPopup.callCount).to.equal(item.showClusterCheckPopupCalledCount); + expect(App.showUpgradeConfigsMergePopup.callCount).to.equal(item.showUpgradeConfigsMergePopupCalledCount); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/8690cfdb/ambari-web/test/views/common/modal_popups/upgrade_configs_merge_popup_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/modal_popups/upgrade_configs_merge_popup_test.js b/ambari-web/test/views/common/modal_popups/upgrade_configs_merge_popup_test.js new file mode 100644 index 0000000..292060d --- /dev/null +++ b/ambari-web/test/views/common/modal_popups/upgrade_configs_merge_popup_test.js @@ -0,0 +1,91 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +var App = require('app'); +require('views/common/modal_popups/upgrade_configs_merge_popup'); + +describe('App.showUpgradeConfigsMergePopup', function () { + + var conflicts = [ + { + type: 't0', + property: 'p0', + current: 'c0', + new_stack_value: 'n0', + result_value: 'n0' + }, + { + type: 't1', + property: 'p1', + current: 'c1', + new_stack_value: null, + result_value: 'c1' + }, + { + type: 't2', + property: 'p2', + current: 'c2', + new_stack_value: null, + result_value: null + } + ], + version = 'HDP-2.3.0.0-1111', + result = [ + { + type: 't0', + name: 'p0', + currentValue: 'c0', + recommendedValue: 'n0', + resultingValue: 'n0', + isDeprecated: false, + willBeRemoved: false + }, + { + type: 't1', + name: 'p1', + currentValue: 'c1', + recommendedValue: Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.deprecated'), + resultingValue: 'c1', + isDeprecated: true, + willBeRemoved: false + }, + { + type: 't2', + name: 'p2', + currentValue: 'c2', + recommendedValue: Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.deprecated'), + resultingValue: Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.willBeRemoved'), + isDeprecated: true, + willBeRemoved: true + } + ], + isPrimaryCalled = false, + primary = function () { + isPrimaryCalled = true; + }; + + it('popup with configs merge warnings', function () { + var popup = App.showUpgradeConfigsMergePopup(conflicts, version , primary); + expect(popup.get('header')).to.equal(Em.I18n.t('popup.clusterCheck.Upgrade.header').format(version)); + expect(popup.get('bodyClass').create().get('configs')).to.eql(result); + popup.onPrimary(); + expect(isPrimaryCalled).to.be.true; + }); + +});
