Przeglądaj źródła

AMBARI-18931. Can't change capacity-scheduler's queue capacity from the YARN config page, even though its shown as text box (akovalenko)

Aleksandr Kovalenko 8 lat temu
rodzic
commit
f1a25944ca

+ 15 - 5
ambari-web/app/mixins/common/configs/config_recommendation_parser.js

@@ -155,11 +155,21 @@ App.ConfigRecommendationParser = Em.Mixin.create(App.ConfigRecommendations, {
 
     Em.set(config, 'recommendedValue', recommendedValue);
     if (this.allowUpdateProperty(parentProperties, Em.get(config, 'name'), Em.get(config, 'filename'))) {
-      Em.setProperties(config, {
-        value: recommendedValue,
-        errorMessage: '',
-        warnMessage: ''
-      });
+      var allowConfigUpdate = true;
+      // workaround for capacity-scheduler
+      if (this.get('currentlyChangedConfig')) {
+        var cId = App.config.configId(this.get('currentlyChangedConfig.name'), this.get('currentlyChangedConfig.fileName'));
+        if (App.config.configId(config.get('name'), config.get('filename')) === cId) {
+          allowConfigUpdate = false;
+        }
+      }
+      if (allowConfigUpdate) {
+        Em.setProperties(config, {
+          value: recommendedValue,
+          errorMessage: '',
+          warnMessage: ''
+        });
+      }
       if (!Em.isNone(recommendedValue) && !Em.get(config, 'hiddenBySection')) {
         Em.set(config, 'isVisible', true);
       }

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

@@ -227,4 +227,4 @@ App.ConfigRecommendations = Em.Mixin.create({
     this.set('recommendations', filteredRecommendations);
   }
 
-});
+});

+ 24 - 4
ambari-web/app/mixins/common/configs/enhanced_configs.js

@@ -62,6 +62,14 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
    */
   isControllerSupportsEnhancedConfigs: Em.computed.existsIn('name', ['wizardStep7Controller','mainServiceInfoConfigsController']),
 
+  /**
+   * Stores name and file name of changed config
+   * This used only for capacity-scheduler
+   *
+   * @property {object}
+   */
+  currentlyChangedConfig: null,
+
   dependenciesGroupMessage: Em.I18n.t('popup.dependent.configs.dependencies.for.groups'),
   /**
    * message fro alert box for dependent configs
@@ -172,6 +180,14 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
       if (updateDependencies) {
         dataToSend.changed_configurations = changedConfigs;
       }
+      if (Em.isArray(changedConfigs) && changedConfigs.mapProperty('type').uniq()[0] === 'capacity-scheduler') {
+        this.set('currentlyChangedConfig', {
+          name: 'capacity-scheduler',
+          fileName: 'capacity-scheduler.xml'
+        });
+      } else {
+        this.set('currentlyChangedConfig', null);
+      }
 
       if (configGroup && !configGroup.get('isDefault') && configGroup.get('hosts.length') > 0) {
         recommendations.config_groups = [this.buildConfigGroupJSON(this.get('selectedService.configs'), configGroup)];
@@ -235,9 +251,13 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
     return this.get('selectedConfigGroup.isDefault') && !Em.isNone(this.get('recommendationsConfigs'))
       && !this.get('stepConfigs').filter(function(stepConfig) {
       return stepConfig.get('changedConfigProperties').filter(function(c) {
-        return !this.get('changedProperties').map(function(changed) {
+        var changedConfigIds = this.get('changedProperties').map(function(changed) {
           return App.config.configId(changed.propertyName, changed.propertyFileName);
-        }).contains(App.config.configId(c.get('name'), c.get('filename')));
+        });
+        if (this.get('currentlyChangedConfig')) {
+          return changedConfigIds.contains(App.config.configId(this.get('currentlyChangedConfig.name'), this.get('currentlyChangedConfig.fileName')));
+        }
+        return !changedConfigIds.contains(App.config.configId(c.get('name'), c.get('filename')));
       }, this).length;
     }, this).length;
   },
@@ -414,13 +434,13 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
       }
     }, this);
   },
-  
+
   saveInitialRecommendations: function() {
     this.get('recommendations').forEach(function (r) {
       this.get('initialRecommendations').pushObject(r);
     }, this);
   },
-  
+
   /**
    * disable saving recommended value for current config
    * @param config

+ 9 - 2
ambari-web/app/views/common/controls_view.js

@@ -313,12 +313,19 @@ App.CapacitySceduler = App.ServiceConfigTextArea.extend({
     if (!config.get('isValid') && config.get('isNotDefaultValue')) return $.Deferred().resolve().promise();
     controller = controller || this.get('controller');
     if (controller && ['mainServiceInfoConfigsController','wizardStep7Controller'].contains(controller.get('name'))) {
-      return controller.loadConfigRecommendations(config.get('value').split('\n').map(function (_property) {
+      var schedulerConfigs = config.get('value').split('\n').map(function (_property) {
         return {
           "type": 'capacity-scheduler',
           "name": _property.split('=')[0]
         }
-      }));
+      });
+      if (!schedulerConfigs.someProperty('name', 'capacity-scheduler')) {
+        schedulerConfigs.push({
+          "type": 'capacity-scheduler',
+          "name": 'capacity-scheduler'
+        });
+      }
+      return controller.loadConfigRecommendations(schedulerConfigs);
     }
 
     return $.Deferred().resolve().promise();