AMBARI-15029. Adding a Service results in deleting Config Group mappings (more than 1 CG present) (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7bd0a877 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7bd0a877 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7bd0a877 Branch: refs/heads/2.2.1-maint Commit: 7bd0a87775bfd32e32257c2ceab4c78110c7c0df Parents: 6893b5a Author: Aleksandr Kovalenko <akovale...@hortonworks.com> Authored: Fri Feb 12 16:55:58 2016 +0200 Committer: Yusaku Sako <yus...@hortonworks.com> Committed: Fri Feb 12 10:30:31 2016 -0800 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 2 +- ambari-web/app/controllers/wizard.js | 4 +++- .../app/controllers/wizard/step7_controller.js | 21 ++++++++++++++------ ambari-web/app/routes/add_service_routes.js | 1 + ambari-web/app/utils/config.js | 18 +++++++++-------- ambari-web/test/controllers/wizard_test.js | 5 ++--- 6 files changed, 32 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7bd0a877/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index 0447392..f265c66 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -485,7 +485,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A } } else { var isEditable = self.get('canEdit') && configGroup.get('name') == self.get('selectedConfigGroup.name'); - allConfigs.push(App.config.createCustomGroupConfig(prop, config, configGroup, isEditable)); + allConfigs.push(App.config.createCustomGroupConfig(prop, config.type, config.properties[prop], configGroup, isEditable)); } } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7bd0a877/ambari-web/app/controllers/wizard.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js index ad78d8c..aa82234 100644 --- a/ambari-web/app/controllers/wizard.js +++ b/ambari-web/app/controllers/wizard.js @@ -870,11 +870,13 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM installedServiceNamesMap[name] = true; }); stepController.get('stepConfigs').forEach(function (_content) { - if (_content.serviceName === 'YARN') { _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'), 'capacity-scheduler.xml')); } _content.get('configs').forEach(function (_configProperties) { + if (!Em.isNone(_configProperties.get('group'))) { + return false; + } var configProperty = App.config.createDefaultConfig( _configProperties.get('name'), _configProperties.get('serviceName'), http://git-wip-us.apache.org/repos/asf/ambari/blob/7bd0a877/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index 4b27c76..2515219 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -531,6 +531,9 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E if (Em.isNone(serviceConfigProperty.get('isOverridable'))) { serviceConfigProperty.set('isOverridable', true); } + if (!Em.isNone(serviceConfigProperty.get('group'))) { + serviceConfigProperty.get('group.properties').pushObject(serviceConfigProperty); + } this._updateOverridesForConfig(serviceConfigProperty, component); this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected); @@ -1268,23 +1271,28 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E var readyGroup = App.ConfigGroup.create(configGroup); var wrappedProperties = []; readyGroup.get('properties').forEach(function (propertyData) { - var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name); - var overriddenSCP = App.ServiceConfigProperty.create(parentSCP); + var overriddenSCP, parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name); + if (parentSCP) { + overriddenSCP = App.ServiceConfigProperty.create(parentSCP); + overriddenSCP.set('parentSCP', parentSCP); + } else { + overriddenSCP = App.config.createCustomGroupConfig(propertyData.name, propertyData.filename, propertyData.value, readyGroup, true, false); + this.get('stepConfigs').findProperty('serviceName', service.serviceName).get('configs').pushObject(overriddenSCP); + } overriddenSCP.set('isOriginalSCP', false); - overriddenSCP.set('parentSCP', parentSCP); overriddenSCP.set('group', readyGroup); overriddenSCP.setProperties(propertyData); wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP)); - }); + }, this); wrappedProperties.setEach('group', readyGroup); readyGroup.set('properties', wrappedProperties); readyGroup.set('parentConfigGroup', defaultGroup); serviceGroups.pushObject(readyGroup); - }); + }, this); defaultGroup.set('childConfigGroups', serviceGroups); serviceGroups.pushObject(defaultGroup); } - }); + }, this); }, /** @@ -1365,6 +1373,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E * @method _setOverrides */ _setOverrides: function (config, overrides) { + if (config.get('group')) return config; var selectedGroup = this.get('selectedConfigGroup'), overrideToAdd = this.get('overrideToAdd'), configOverrides = overrides.filterProperty('name', config.get('name')); http://git-wip-us.apache.org/repos/asf/ambari/blob/7bd0a877/ambari-web/app/routes/add_service_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js index 85be52b..ea3baa1 100644 --- a/ambari-web/app/routes/add_service_routes.js +++ b/ambari-web/app/routes/add_service_routes.js @@ -205,6 +205,7 @@ module.exports = App.WizardRoute.extend({ recommendationsConfigs: null }); router.get('wizardStep7Controller').set('recommendationsConfigs', null); + addServiceController.setDBProperty('serviceConfigGroups', undefined); router.transitionTo('step4'); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7bd0a877/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index f478fd3..c6620a3 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -858,19 +858,20 @@ App.config = Em.Object.create({ loadServiceConfigGroupOverridesSuccess: function (data, opt, params) { data.items.forEach(function (config) { + var hostOverrideValue, hostOverrideIsFinal; var group = params.typeTagToGroupMap[config.type + "///" + config.tag]; var properties = config.properties; for (var prop in properties) { var fileName = this.getOriginalFileName(config.type); var serviceConfig = !!params.configKeyToConfigMap[fileName] ? params.configKeyToConfigMap[fileName][prop] : false; - var hostOverrideValue = this.formatPropertyValue(serviceConfig, properties[prop]); - var hostOverrideIsFinal = !!(config.properties_attributes && config.properties_attributes.final && config.properties_attributes.final[prop]); if (serviceConfig) { // Value of this property is different for this host. + hostOverrideValue = this.formatPropertyValue(serviceConfig, properties[prop]); + hostOverrideIsFinal = !!(config.properties_attributes && config.properties_attributes.final && config.properties_attributes.final[prop]); if (!Em.get(serviceConfig, 'overrides')) Em.set(serviceConfig, 'overrides', []); serviceConfig.overrides.pushObject({value: hostOverrideValue, group: group, isFinal: hostOverrideIsFinal}); } else { - params.serviceConfigs.push(this.createCustomGroupConfig(prop, config, group)); + params.serviceConfigs.push(this.createCustomGroupConfig(prop, config.type, config.properties[prop], group)); } } }, this); @@ -882,15 +883,16 @@ App.config = Em.Object.create({ * can be created and assigned to non-default config group. * * @param {String} propertyName - name of the property - * @param {Object} config - config info + * @param {String} filename - config filename + * @param {String} value - property value * @param {Em.Object} group - config group to set * @param {Boolean} isEditable * @return {Object} **/ - createCustomGroupConfig: function (propertyName, config, group, isEditable) { - var propertyObject = this.createDefaultConfig(propertyName, group.get('service.serviceName'), this.getOriginalFileName(config.type), false, { - savedValue: config.properties[propertyName], - value: config.properties[propertyName], + createCustomGroupConfig: function (propertyName, filename, value, group, isEditable) { + var propertyObject = this.createDefaultConfig(propertyName, group.get('service.serviceName'), this.getOriginalFileName(filename), false, { + savedValue: value, + value: value, group: group, isEditable: isEditable !== false, isOverridable: false http://git-wip-us.apache.org/repos/asf/ambari/blob/7bd0a877/ambari-web/test/controllers/wizard_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js index 035e0ab..ea329d7 100644 --- a/ambari-web/test/controllers/wizard_test.js +++ b/ambari-web/test/controllers/wizard_test.js @@ -1004,7 +1004,6 @@ describe('App.WizardController', function () { isRequiredByAgent: true, hasInitialValue: true, isRequired: true, - group: {name: 'group'}, showLabel: true, category: 'some_category' }) @@ -1038,10 +1037,10 @@ describe('App.WizardController', function () { }) ]}); - it('should save configs to content.serviceConfigProperties', function () { + it('should save configs from default config group to content.serviceConfigProperties', function () { c.saveServiceConfigProperties(stepController); var saved = c.get('content.serviceConfigProperties'); - expect(saved.length).to.equal(2); + expect(saved.length).to.equal(1); expect(saved[0].category).to.equal('some_category'); });