Procházet zdrojové kódy

AMBARI-7491 Error message appeared during adding services. (ababiichuk)

aBabiichuk před 10 roky
rodič
revize
cb3e2eef27

+ 26 - 4
ambari-web/app/controllers/wizard.js

@@ -886,11 +886,11 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    */
   saveServiceConfigGroups: function (stepController, isAddService) {
     var serviceConfigGroups = [],
-      isForUpdate = false,
+      isForInstalledService = false,
       hosts = isAddService ? App.router.get('addServiceController').getDBProperty('hosts') : this.getDBProperty('hosts');
     stepController.get('stepConfigs').forEach(function (service) {
       // mark group of installed service
-      if (service.get('selected') === false) isForUpdate = true;
+      if (service.get('selected') === false) isForInstalledService = true;
       service.get('configGroups').forEach(function (configGroup) {
         var properties = [];
         configGroup.get('properties').forEach(function (property) {
@@ -903,14 +903,16 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
           })
         });
         //configGroup copied into plain JS object to avoid Converting circular structure to JSON
+        var hostNames = configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;});
         serviceConfigGroups.push({
           id: configGroup.get('id'),
           name: configGroup.get('name'),
           description: configGroup.get('description'),
-          hosts: configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;}),
+          hosts: hostNames,
           properties: properties,
           isDefault: configGroup.get('isDefault'),
-          isForUpdate: isForUpdate,
+          isForInstalledService: isForInstalledService,
+          isForUpdate: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
           service: {id: configGroup.get('service.id')}
         });
       }, this)
@@ -918,6 +920,26 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
     this.setDBProperty('serviceConfigGroups', serviceConfigGroups);
     this.set('content.configGroups', serviceConfigGroups);
   },
+
+  /**
+   * generate string hash for config group
+   * @param {Object} configGroup
+   * @param {Array|undefined} hosts
+   * @returns {String|null}
+   * @method getConfigGroupHash
+   */
+  getConfigGroupHash: function(configGroup,  hosts) {
+    if (!Em.get(configGroup, 'properties.length') && !Em.get(configGroup, 'hosts.length') && !hosts) {
+      return null;
+    }
+    var hash = {};
+    Em.get(configGroup, 'properties').forEach(function (config) {
+      hash[Em.get(config, 'name')] = {value: Em.get(config, 'value'), isFinal: Em.get(config, 'isFinal')};
+    });
+    hash['hosts'] = hosts || Em.get(configGroup, 'hosts');
+    return JSON.stringify(hash);
+  },
+
   /**
    * return slaveComponents bound to hosts
    * @return {Array}

+ 3 - 3
ambari-web/app/controllers/wizard/step7_controller.js

@@ -17,8 +17,6 @@
  */
 
 var App = require('app');
-var numberUtils = require('utils/number_utils');
-var stringUtils = require('utils/string_utils');
 /**
  * By Step 7, we have the following information stored in App.db and set on this
  * controller by the router.
@@ -645,7 +643,9 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
       serviceConfigProperty.validate();
 
     }, this);
-
+    component.get('configGroups').filterProperty('isDefault', false).forEach(function(configGroup) {
+      configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
+    }, this);
     var overrideToAdd = this.get('overrideToAdd');
     if (overrideToAdd) {
       overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);

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

@@ -1523,11 +1523,11 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
       });
       groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
       // check for group from installed service
-      if (configGroup.isForUpdate === true) {
+      if (configGroup.isForInstalledService === true) {
         // if group is a new one, create it
         if (!configGroup.id) {
           sendData.push({"ConfigGroup": groupData});
-        } else {
+        } else if (configGroup.isForUpdate){
           // update an existing group
           groupData.id = configGroup.id;
           updateData.push({"ConfigGroup": groupData});

+ 9 - 6
ambari-web/app/models/config_group.js

@@ -82,14 +82,15 @@ App.ConfigGroup = Ember.Object.extend({
   hosts: [],
 
   /**
-   * In add service wizard we have installed services.
-   * And on deploy step we need to update existing config groups
-   * also mark it for be sure that config group data came from
-   * installed service.
-   *
+   * this flag is used for installed services' config groups
+   * if user make changes to them - mark this flag to true
    */
   isForUpdate: false,
 
+  /**
+   * mark config groups for installed services
+   */
+  isForInstalledService: false,
   /**
    * Provides a display friendly name. This includes trimming
    * names to a certain length.
@@ -158,5 +159,7 @@ App.ConfigGroup = Ember.Object.extend({
       result += item.name + " : " + item.value + '<br/>';
     }, this);
     return result;
-  }.property('properties.length')
+  }.property('properties.length'),
+
+  hash: null
 });

+ 8 - 6
ambari-web/app/models/service_config.js

@@ -857,12 +857,14 @@ App.ServiceConfigProperty = Ember.Object.extend({
             isError = true;
           } else {
             var overrides = parentSCP.get('overrides');
-            overrides.forEach(function (override) {
-              if (self != override && value === override.get('value')  && supportsFinal && isFinal === parentSCP.get('isFinal')) {
-                self.set('errorMessage', 'Multiple configuration overrides cannot have same value');
-                isError = true;
-              }
-            });
+            if (overrides) {
+              overrides.forEach(function (override) {
+                if (self != override && value === override.get('value')  && supportsFinal && isFinal === parentSCP.get('isFinal')) {
+                  self.set('errorMessage', 'Multiple configuration overrides cannot have same value');
+                  isError = true;
+                }
+              });
+            }
           }
         }
       }