Browse Source

AMBARI-11962. Some added properties changing during deploy (alexantonenko)

Alex Antonenko 10 years ago
parent
commit
0930a74fc5

+ 11 - 2
ambari-web/app/controllers/wizard/step8_controller.js

@@ -384,13 +384,22 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
     var dependentConfig = $.extend(true, [], configMapping.filterProperty('foreignKey'));
     dependentConfig.forEach(function (_config) {
       App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config);
-      if(!_config.noMatchSoSkipThisConfig)
+      // generated config name using template for example `hadoop.proxyuser.hive.hosts`
+      var configName = _config._name || _config.name;
+      // property from <code>content.serviceConfigProperties</code>. This property can be added in custom-site.xml
+      // with the same name as propety from defined config mapping. In this case property from config mapping
+      // object should be ignored.
+      var isPropertyDefined = this.get('content.serviceConfigProperties')
+            .filterProperty('filename', _config.filename).someProperty('name', configName);
+      // ignore config mapping property if no matches for template was found or property already added by user
+      if(!_config.noMatchSoSkipThisConfig && !isPropertyDefined) {
         uiConfig.pushObject({
           "id": "site property",
-          "name": _config._name || _config.name,
+          "name": configName,
           "value": _config.value,
           "filename": _config.filename
         });
+      }
     }, this);
     return uiConfig;
   },

+ 9 - 2
ambari-web/test/controllers/wizard/step8_test.js

@@ -1765,9 +1765,13 @@ describe('App.WizardStep8Controller', function () {
   describe('#loadUiSideConfigs', function() {
     beforeEach(function() {
       sinon.stub(App.config, 'setConfigValue', Em.K);
+      sinon.stub(installerStep8Controller, 'get').withArgs('content.serviceConfigProperties').returns([
+        { name: 'c9', filename: 'f3'}
+      ]);
     });
     afterEach(function() {
       App.config.setConfigValue.restore();
+      installerStep8Controller.get.restore();
     });
 
     it('configs with foreignKey', function() {
@@ -1775,10 +1779,13 @@ describe('App.WizardStep8Controller', function () {
         {foreignKey: 'fk1', templateName: 't5', value: 'v5', name: 'c5', filename: 'f1'},
         {foreignKey: 'fk2', templateName: 't6', value: 'v6', name: 'c6', filename: 'f1'},
         {foreignKey: 'fk3', templateName: 't7', value: 'v7', name: 'c7', filename: 'f2'},
-        {foreignKey: 'fk4', templateName: 't8', value: 'v8', name: 'c8', filename: 'f2'}
+        {foreignKey: 'fk4', templateName: 't8', value: 'v8', name: 'c8', filename: 'f2'},
+        {foreignKey: 'fk5', templateName: 't9', value: 'v9', name: 'c9', filename: 'f3'}
       ];
       var uiConfigs = installerStep8Controller.loadUiSideConfigs(configMapping);
-      expect(uiConfigs.length).to.equal(configMapping.length);
+      // should ignore one config that was saved in contentServiceConfigProperties
+      expect(uiConfigs.length).to.equal(configMapping.length - 1);
+      expect(uiConfigs.findProperty('name', 'c9')).to.be.undefined;
       expect(uiConfigs.everyProperty('id', 'site property')).to.be.true;
       uiConfigs.forEach(function(c, index) {
         if (Em.isNone(configMapping[index].foreignKey))