Jelajahi Sumber

AMBARI-12184. Unable to save configs if there is two config groups with the same property value (akovalenko)

Aleksandr Kovalenko 10 tahun lalu
induk
melakukan
d90a101c2d

+ 0 - 1
ambari-web/app/messages.js

@@ -409,7 +409,6 @@ Em.I18n.translations = {
   'host.spacesValidation': 'Cannot contain whitespace',
   'host.spacesValidation': 'Cannot contain whitespace',
   'host.trimspacesValidation': 'Cannot contain leading or trailing whitespace',
   'host.trimspacesValidation': 'Cannot contain leading or trailing whitespace',
   'config.override.valueEqualToParentConfig': 'Configuration overrides must have different value',
   'config.override.valueEqualToParentConfig': 'Configuration overrides must have different value',
-  'config.override.valueEqualToAnotherOverrideConfig': 'Multiple configuration overrides cannot have same value',
 
 
   'services.hdfs.rebalance.title' : 'HDFS Rebalance',
   'services.hdfs.rebalance.title' : 'HDFS Rebalance',
   'services.ganglia.description':'Ganglia Metrics Collection system',
   'services.ganglia.description':'Ganglia Metrics Collection system',

+ 20 - 25
ambari-web/app/models/configs/objects/service_config_property.js

@@ -481,46 +481,41 @@ App.ServiceConfigProperty = Em.Object.extend({
    * @method _validateOverrides
    * @method _validateOverrides
    */
    */
   _validateOverrides: function () {
   _validateOverrides: function () {
-    var self = this;
     var isError = false;
     var isError = false;
     var value = this._getValueForCheck(this.get('value'));
     var value = this._getValueForCheck(this.get('value'));
     var isOriginalSCP = this.get('isOriginalSCP');
     var isOriginalSCP = this.get('isOriginalSCP');
     var supportsFinal = this.get('supportsFinal');
     var supportsFinal = this.get('supportsFinal');
     var isFinal = this.get('isFinal');
     var isFinal = this.get('isFinal');
     var parentSCP = this.get('parentSCP');
     var parentSCP = this.get('parentSCP');
-    if (!isOriginalSCP) {
-      if (!Em.isNone(parentSCP)) {
-        if (value === this._getValueForCheck(parentSCP.get('value'))) {
-          if (supportsFinal) {
-            if (isFinal === parentSCP.get('isFinal')) {
+    var overrides = this.get('overrides');
+    if (isOriginalSCP) {
+      if (overrides) {
+        overrides.forEach(function (override) {
+          if (value === this._getValueForCheck(override.get('value'))) {
+            if (supportsFinal) {
+              if (isFinal === override.get('isFinal')) {
+                this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig'));
+                isError = true;
+              }
+            }
+            else {
               this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig'));
               this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig'));
               isError = true;
               isError = true;
             }
             }
           }
           }
-          else {
+        }, this);
+      }
+    } else {
+      if (!Em.isNone(parentSCP) && value === this._getValueForCheck(parentSCP.get('value'))) {
+        if (supportsFinal) {
+          if (isFinal === parentSCP.get('isFinal')) {
             this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig'));
             this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig'));
             isError = true;
             isError = true;
           }
           }
         }
         }
         else {
         else {
-          var overrides = parentSCP.get('overrides');
-          if (overrides) {
-            overrides.forEach(function (override) {
-              if (self == override) return;
-              if (value === self._getValueForCheck(override.get('value'))) {
-                if (supportsFinal) {
-                  if (isFinal === parentSCP.get('isFinal')) {
-                    self.set('errorMessage', Em.I18n.t('config.override.valueEqualToAnotherOverrideConfig'));
-                    isError = true;
-                  }
-                }
-                else {
-                  self.set('errorMessage', Em.I18n.t('config.override.valueEqualToAnotherOverrideConfig'));
-                  isError = true;
-                }
-              }
-            });
-          }
+          this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig'));
+          isError = true;
         }
         }
       }
       }
     }
     }

+ 0 - 19
ambari-web/test/models/configs/objects/service_config_property_test.js

@@ -530,25 +530,6 @@ describe('App.ServiceConfigProperty', function () {
           })
           })
         }
         }
       },
       },
-      {
-        m: 'not original config, parent override has same value',
-        e: true,
-        c: {
-          value: 'on',
-          isOriginalSCP: false,
-          supportsFinal: true,
-          isFinal: false,
-          parentSCP: App.ServiceConfigProperty.create({
-            value: 'off',
-            overrides: [
-              App.ServiceConfigProperty.create({
-                value: 'on',
-                isOriginalSCP: false
-              })
-            ]
-          })
-        }
-      },
       {
       {
         m: 'not original config, parent override doesn\'t have same value',
         m: 'not original config, parent override doesn\'t have same value',
         e: false,
         e: false,