Переглянути джерело

AMBARI-7539 Restart indicator shows up when it should not after reconfiguring service and config groups are involved. (ababiichuk)

aBabiichuk 10 роки тому
батько
коміт
2f5738ccd3

+ 2 - 0
ambari-web/app/app.js

@@ -72,6 +72,8 @@ module.exports = Em.Application.create({
     return Em.get((this.get('currentStackVersion') || this.get('defaultStackVersion')).match(/(.+)-\d.+/), '1');
   }.property('currentStackVersion'),
 
+  allHostNames: [],
+
   currentStackVersionNumber: function () {
     var regExp = new RegExp(this.get('currentStackName') + '-');
     return (this.get('currentStackVersion') || this.get('defaultStackVersion')).replace(regExp, '');

+ 22 - 0
ambari-web/app/controllers/global/cluster_controller.js

@@ -248,6 +248,7 @@ App.ClusterController = Em.Controller.extend({
    */
   loadClusterData: function () {
     var self = this;
+    this.getAllHostNames();
     this.loadAmbariProperties();
     if (!App.get('clusterName')) {
       return;
@@ -390,5 +391,26 @@ App.ClusterController = Em.Controller.extend({
       complete: function () {
       }
     });
+  },
+
+  /**
+   *
+   * @returns {*|Transport|$.ajax|boolean|ServerResponse}
+   */
+  getAllHostNames: function () {
+    return App.ajax.send({
+      name: 'hosts.all',
+      sender: this,
+      success: 'getHostNamesSuccess',
+      error: 'getHostNamesError'
+    });
+  },
+
+  getHostNamesSuccess: function (data) {
+    App.set("allHostNames", data.items.mapProperty("Hosts.host_name"));
+  },
+
+  getHostNamesError: function () {
+    console.error('failed to load hostNames');
   }
 });

+ 1 - 0
ambari-web/app/controllers/main/host/add_controller.js

@@ -371,6 +371,7 @@ App.AddHostController = App.WizardController.extend({
     this.clearStorageData();
     App.router.get('updateController').updateAll();
     App.updater.immediateRun('updateHost');
+    App.router.get('clusterController').getAllHostNames();
   },
 
   /**

+ 1 - 0
ambari-web/app/controllers/main/host/details.js

@@ -1531,6 +1531,7 @@ App.MainHostDetailsController = Em.Controller.extend({
           dialogSelf.hide();
           App.router.transitionTo('hosts.index');
         });
+        App.router.get('clusterController').getAllHostNames();
       },
       deleteHostErrorCallback: function (xhr, textStatus, errorThrown, opt) {
         console.log('Error deleting host.');

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

@@ -450,7 +450,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
     var serviceName = this.get('content.serviceName');
     var displayName = this.get('content.displayName');
     var selectedConfigGroup;
-    var hostsLength = App.router.get('mainHostController.hostsCountMap.TOTAL');
+    var defaultHosts = App.get('allHostNames');
 
     //parse loaded config groups
     if (App.supports.hostOverrides) {
@@ -470,7 +470,9 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
               hosts: groupHosts,
               configSiteTags: []
             });
-            hostsLength -= groupHosts.length;
+            for (var i = 0; i< groupHosts.length ; i++) {
+              defaultHosts = defaultHosts.without(groupHosts[i]);
+            }
             item.desired_configs.forEach(function (config) {
               newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
                 site: config.type,
@@ -491,9 +493,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
       name: displayName + " Default",
       description: "Default cluster level " + serviceName + " configuration",
       isDefault: true,
-      hosts: {
-        length: hostsLength
-      },
+      hosts: defaultHosts,
       parentConfigGroup: null,
       service: this.get('content'),
       serviceName: serviceName,

+ 1 - 0
ambari-web/app/mappers/service_config_version_mapper.js

@@ -27,6 +27,7 @@ App.serviceConfigVersionsMapper = App.QuickDataMapper.create({
     create_time: 'createtime',
     group_id: 'group_id',
     group_name: 'group_name',
+    hosts: 'hosts',
     author: 'user',
     notes: 'service_config_version_note',
     is_current: 'is_current',

+ 5 - 46
ambari-web/app/mixins/common/serverValidator.js

@@ -43,9 +43,6 @@ App.ServerValidatorMixin = Em.Mixin.create({
    */
   recommendationsConfigs: null,
 
-  loadAdditionalinfo: function() {
-    return !(this.get('content.hosts') && this.get('content.hosts').length);
-  }.property('content.hosts'),
   /**
    * by default loads data from model otherwise must be overridden as computed property
    * refer to \assets\data\stacks\HDP-2.1\recommendations_configs.json to learn structure
@@ -55,8 +52,8 @@ App.ServerValidatorMixin = Em.Mixin.create({
   hostNames: function() {
     return this.get('content.hosts')
         ? Object.keys(this.get('content.hosts'))
-        : this.get('allHostNames');
-  }.property('content.hosts', 'allHostNames'),
+        : App.get('allHostNames');
+  }.property('content.hosts', 'App.allHostNames'),
 
   allHostNames: [],
   /**
@@ -139,21 +136,14 @@ App.ServerValidatorMixin = Em.Mixin.create({
     console.error('Load recommendations failed');
   },
 
-  serverSideValidation: function() {
+  serverSideValidation: function () {
     var deferred = $.Deferred();
     if (!App.get('supports.serverRecommendValidate')) {
       deferred.resolve();
     } else {
       this.set('configValidationFailed', false);
-      if (this.get('loadAdditionalinfo')) {
-        var self = this;
-        this.getHostNames().always(function() {
-          if (self.get('configValidationFailed')) {
-            self.warnUser(deferred);
-          } else {
-            self.runServerSideValidation(deferred);
-          }
-        });
+      if (this.get('configValidationFailed')) {
+        this.warnUser(deferred);
       } else {
         this.runServerSideValidation(deferred);
       }
@@ -161,37 +151,6 @@ App.ServerValidatorMixin = Em.Mixin.create({
     return deferred;
   },
 
-  getHostNames: function() {
-    var self = this;
-
-    if (self.get('isInstaller')) {
-      // In installer wizard 'hosts.all' AJAX will not work cause cluster haven't been created yet
-      var hosts = [];
-      for (var host in self.get('content.hosts')) {
-        hosts.push(host);
-      }
-      self.set("allHostNames", hosts);
-      var deferred = $.Deferred();
-      deferred.resolve();
-      return deferred;
-    } else {
-      return App.ajax.send({
-        name: 'hosts.all',
-        sender: self,
-        success: 'getHostNamesSuccess',
-        error: 'getHostNamesError'
-      });
-    }
-  },
-
-  getHostNamesSuccess: function(data) {
-    this.set("allHostNames", data.items.mapProperty("Hosts.host_name"));
-  },
-
-  getHostNamesError: function() {
-    this.set('configValidationFailed', true);
-    console.error('failed to load hostNames');
-  },
   /**
    * @method serverSideValidation
    * send request to validate configs

+ 19 - 4
ambari-web/app/models/service_config_version.js

@@ -33,15 +33,19 @@ App.ServiceConfigVersion = DS.Model.extend({
   author: DS.attr('string'),
   notes: DS.attr('string'),
   service: DS.belongsTo('App.Service'),
+  hosts: DS.attr('array'),
   index: DS.attr('number'),
   isCurrent: DS.attr('boolean'),
   isDisplayed: DS.attr('boolean'),
+  isDefault: function() {
+    return this.get('groupName') === 'default';
+  }.property('groupName'),
   currentTooltip: function () {
     return Em.I18n.t('dashboard.configHistory.table.current.tooltip').format(this.get('displayName'), this.get('configGroupName'));
   }.property('displayName', 'configGroupName'),
   configGroupName: function () {
-    return (this.get('groupName') === 'default') ? (this.get('displayName') + ' ' + Em.I18n.t('common.default')) : this.get('groupName');
-  }.property('groupName'),
+    return this.get('isDefault') ? (this.get('displayName') + ' ' + Em.I18n.t('common.default')) : this.get('groupName');
+  }.property('groupName','isDefault'),
   fullNotes: function () {
     return (typeof this.get('notes') === 'string') ? this.get('notes') || Em.I18n.t('dashboard.configHistory.table.notes.no') : Em.I18n.t('dashboard.configHistory.table.notes.no');
   }.property('notes'),
@@ -68,8 +72,19 @@ App.ServiceConfigVersion = DS.Model.extend({
    */
   isRequested: DS.attr('boolean'),
   isRestartRequired: function () {
-    return this.get('service.isRestartRequired') && this.get('isCurrent');
-  }.property('service.isRestartRequired', 'isCurrent'),
+    if (this.get('service.isRestartRequired') && this.get('isCurrent')) {
+      var hostNames = this.get('isDefault')
+        ? App.router.get('mainServiceInfoConfigsController.configGroups').findProperty('isDefault').get('hosts')
+        : this.get('hosts');
+      if (!hostNames.length) return false;
+      for (var i = 0; i < hostNames.length; i++) {
+        if (Object.keys(this.get('service.restartRequiredHostsAndComponents')).contains(hostNames[i])) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }.property('service.isRestartRequired','isDefault', 'isCurrent', 'hosts', 'service.restartRequiredHostsAndComponents', 'router.mainServiceInfoConfigsController.configGroups'),
   disabledActionMessages: function () {
     return {
       view: (this.get('isDisplayed')) ? Em.I18n.t('dashboard.configHistory.info-bar.view.button.disabled') : '',

+ 1 - 1
ambari-web/app/utils/ajax/ajax.js

@@ -1882,7 +1882,7 @@ var urls = {
     }
   },
   'service.serviceConfigVersions.get': {
-    real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&fields=service_config_version,user,group_id,group_name,is_current,createtime,service_name,service_config_version_note&minimal_response=true',
+    real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&fields=service_config_version,user,hosts,group_id,group_name,is_current,createtime,service_name,service_config_version_note&minimal_response=true',
     mock: '/data/configurations/service_versions.json'
   },
   'service.serviceConfigVersions.get.current': {