Browse Source

AMBARI-11925. Kerkeros Service Configs: KDC Type Value is corrupted (rlevas)

Robert Levas 10 years ago
parent
commit
cbc0160735

+ 20 - 0
ambari-web/app/controllers/main/service/info/configs.js

@@ -401,6 +401,26 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A
     this.addHostNamesToConfig();
   },
 
+  /**
+   * revert certain config values to their innital value
+   * i.e. don't save the KDC Type as "Existing MIT KDC", instead save it as mit-kdc
+   */
+  configValueRevert: function () {
+    var stepConfigs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName'));
+    if (!stepConfigs) { return; }
+
+    var configs = stepConfigs.configs;
+    if (configs) {
+      var kdc_type = configs.findProperty('name', 'kdc_type');
+
+      if (!kdc_type) { return; };
+      if (App.router.get('mainAdminKerberosController.kdcTypesValues')[kdc_type.get('value')]) { return; }
+
+      kdc_type.set('value', kdc_type.get('savedValue'));
+    }
+
+  }.observes('saveInProgress'),
+
   /**
    * adds properties form stack that doesn't belong to cluster
    * to step configs

+ 1 - 1
ambari-web/app/mixins/common/configs/configs_saver.js

@@ -958,7 +958,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
    */
 
   /**
-   * filter out unchanged configurations
+   * filter out unchanged configurationsisPropertiesChanged
    * @param {Array} configsToSave
    * @private
    * @method filterChangedConfiguration

+ 30 - 4
ambari-web/app/models/configs/objects/service_config.js

@@ -62,12 +62,38 @@ App.ServiceConfig = Ember.Object.extend({
     return masterErrors + slaveErrors + overrideErrors + enhancedConfigsErrors;
   }.property('configs.@each.isValid', 'configs.@each.isVisible', 'configCategories.@each.slaveErrorCount', 'configs.@each.overrideErrorTrigger'),
 
+  /**
+   * checks if for example for kdc_type, the value isn't just the pretty version of the saved value, for example mit-kdc
+   * and Existing MIT KDC are the same value, but they are interpreted as being changed. This function fixes that
+   * @param configs
+   * @returns {boolean} - checks
+   */
+  checkDefaultValues: function (configs) {
+    var kdcType = configs.findProperty('name', 'kdc_type');
+
+    if (!kdcType) {
+      return true;
+    }
+
+    // if there is only one value changed and that value is for kdc_type, check if the value has really changed or just
+    // the string shown to the user is different
+    if (configs.filterProperty('isNotDefaultValue').length === 1) {
+      if (configs.findProperty('isNotDefaultValue', true) === kdcType) {
+        return App.router.get('mainAdminKerberosController.kdcTypesValues')[kdcType.get('savedValue')] !== kdcType.get('value');
+      }
+    }
+
+    return true;
+  },
+
   isPropertiesChanged: function() {
     var requiredByAgent = this.get('configs').filterProperty('isRequiredByAgent');
-    return requiredByAgent.someProperty('isNotSaved') ||
-           requiredByAgent.someProperty('isNotDefaultValue') ||
-           requiredByAgent.someProperty('isOverrideChanged') ||
-           this.get('configs.length') !== this.get('initConfigsLength');
+    var isNotSaved = requiredByAgent.someProperty('isNotSaved');
+    var isNotDefaultValue = this.checkDefaultValues(requiredByAgent);
+    var isOverrideChanged = requiredByAgent.someProperty('isOverrideChanged');
+    var differentConfigLengths = this.get('configs.length') !== this.get('initConfigsLength');
+
+    return  isNotSaved || isNotDefaultValue || isOverrideChanged || differentConfigLengths;
   }.property('configs.@each.isNotDefaultValue', 'configs.@each.isOverrideChanged', 'configs.length', 'configs.@each.isNotSaved', 'initConfigsLength'),
 
   init: function() {