Jelajahi Sumber

AMBARI-11019 AMS config warning message is confusing. (atkach)

Andrii Tkach 10 tahun lalu
induk
melakukan
684ffd294d

+ 28 - 15
ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py

@@ -340,9 +340,37 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
               print("Recommendations: %s\n********\n" % str(siteRecommendations))
               resultItems = method(siteProperties, siteRecommendations, configurations, services, hosts)
               items.extend(resultItems)
+    clusterWideItems = self.validateClusterConfigurations(configurations, services, hosts)
+    items.extend(clusterWideItems)
     self.validateMinMax(items, recommendedDefaults, configurations)
     return items
 
+  def validateClusterConfigurations(self, configurations, services, hosts):
+    validationItems = []
+    hostComponents = {}
+    failureMessage = ""
+
+    for service in services["services"]:
+      for component in service["components"]:
+        if component["StackServiceComponents"]["hostnames"] is not None:
+          for hostName in component["StackServiceComponents"]["hostnames"]:
+            if hostName not in hostComponents.keys():
+              hostComponents[hostName] = []
+            hostComponents[hostName].append(component["StackServiceComponents"]["component_name"])
+
+    for host in hosts["items"]:
+      # Not enough physical memory
+      requiredMemory = getMemorySizeRequired(hostComponents[host["Hosts"]["host_name"]], configurations)
+      if host["Hosts"]["total_mem"] * 1024 < requiredMemory:  # in bytes
+        failureMessage += "Not enough physical RAM on the host {0}. " \
+                          "At least {1} MB is recommended based on components assigned.\n" \
+          .format(host["Hosts"]["host_name"], requiredMemory/1048576)  # MB
+    if failureMessage:
+      notEnoughMemoryItem = self.getWarnItem(failureMessage)
+      validationItems.extend([{"config-name": "", "item": notEnoughMemoryItem}])
+
+    return self.toConfigurationValidationProblems(validationItems, "")
+
   def getServiceConfigurationValidators(self):
     return {
       "HDFS": {"hadoop-env": self.validateHDFSConfigurationsEnv},
@@ -447,16 +475,12 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
     masterHostItem = None
 
     if masterItem is None:
-      hostComponents = {}
       hostMasterComponents = {}
 
       for service in services["services"]:
         for component in service["components"]:
           if component["StackServiceComponents"]["hostnames"] is not None:
             for hostName in component["StackServiceComponents"]["hostnames"]:
-              if hostName not in hostComponents.keys():
-                hostComponents[hostName] = []
-              hostComponents[hostName].append(component["StackServiceComponents"]["component_name"])
               if self.isMasterComponent(component):
                 if hostName not in hostMasterComponents.keys():
                   hostMasterComponents[hostName] = []
@@ -478,17 +502,6 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
               masterHostItem = self.getWarnItem(
                 masterHostMessage.format(
                   collectorHostName, str(", ".join(hostMasterComponents[collectorHostName]))))
-
-            # Not enough physical memory
-            requiredMemory = getMemorySizeRequired(hostComponents[collectorHostName], configurations)
-            if host["Hosts"]["total_mem"] * 1024 < requiredMemory:  # in bytes
-              message = "Not enough total RAM on the host {0}, " \
-                        "at least {1} MB required for the components({2})" \
-                .format(collectorHostName, requiredMemory/1048576,
-                        str(", ".join(hostComponents[collectorHostName])))  # MB
-              regionServerItem = self.getErrorItem(message)
-              masterItem = self.getErrorItem(message)
-              break
       pass
 
     # Check RS memory in distributed mode since we set default as 512m

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

@@ -55,6 +55,7 @@ Em.I18n.translations = {
   'ok':'OK',
   'as':'as',
   'on':'on',
+  'in':'in',
   'any': 'Any',
   'more':'more',
   'yes':'Yes',

+ 8 - 3
ambari-web/app/mixins/common/serverValidator.js

@@ -230,11 +230,16 @@ App.ServerValidatorMixin = Em.Mixin.create({
             var message = {
               propertyName: item['config-name'],
               filename: item['config-type'],
-              warnMessage: item.message,
-              serviceName: App.StackService.find().filter(function(service) {
+              warnMessage: item.message
+            };
+            if (item['config-type'] === "" && item['config-name'] === "") {
+              //service-independent validation
+              message.isGeneral = true;
+            } else {
+              message.serviceName = App.StackService.find().filter(function(service) {
                 return !!service.get('configTypes')[item['config-type']];
               })[0].get('displayName')
-            };
+            }
             self.set(item.level == 'WARN' ? 'configValidationWarning' : 'configValidationError', true);
             globalWarning.push(message);
           }

+ 11 - 5
ambari-web/app/templates/common/modal_popups/config_recommendation_popup.hbs

@@ -57,11 +57,17 @@
         {{/each}}
       {{/each}}
       {{#each message in configValidationGlobalMessage}}
-        <tr>
-          <td>{{message.serviceName}}</td>
-          <td>{{message.propertyName}}</td>
-          <td colspan="2">{{message.warnMessage}} in {{message.filename}}</td>
-        </tr>
+        {{#if message.isGeneral}}
+          <tr>
+            <td colspan="4">{{message.warnMessage}}</td>
+          </tr>
+        {{else}}
+          <tr>
+            <td>{{message.serviceName}}</td>
+            <td>{{message.propertyName}}</td>
+            <td colspan="2">{{message.warnMessage}} {{t in}} {{message.filename}}</td>
+          </tr>
+        {{/if}}
       {{/each}}
     </tbody>
   </table>