소스 검색

AMBARI-4315. Proposed changes to new resource mgmt logging (aonishuk)

Andrew Onischuk 11 년 전
부모
커밋
c4032cbd28

+ 3 - 3
ambari-agent/src/main/python/resource_management/core/environment.py

@@ -130,19 +130,19 @@ class Environment(object):
       # Run resource actions
       while self.resource_list:
         resource = self.resource_list.pop(0)
-        self.log.debug("Running resource %r" % resource)
+        self.log.info("%s %s" % (resource, repr(resource.arguments).replace("': u'","': '")))
         
         if resource.initial_wait:
           time.sleep(resource.initial_wait)
 
         if resource.not_if is not None and self._check_condition(
           resource.not_if):
-          self.log.debug("Skipping %s due to not_if" % resource)
+          self.log.info("Skipping %s due to not_if" % resource)
           continue
 
         if resource.only_if is not None and not self._check_condition(
           resource.only_if):
-          self.log.debug("Skipping %s due to only_if" % resource)
+          self.log.info("Skipping %s due to only_if" % resource)
           continue
 
         for action in resource.action:

+ 0 - 3
ambari-agent/src/main/python/resource_management/core/providers/package/__init__.py

@@ -37,17 +37,14 @@ class PackageProvider(Provider):
 
   def action_install(self):
     package_name = self.get_package_name_with_version()
-    self.log.info("Installing package %s", package_name)
     self.install_package(package_name)
 
   def action_upgrade(self):
     package_name = self.get_package_name_with_version()
-    self.log.info("Upgrading package %s", package_name)
     self.upgrade_package(package_name)
 
   def action_remove(self):
     package_name = self.get_package_name_with_version()
-    self.log.info("Removing package %s", package_name)
     self.remove_package(package_name)
 
   def get_package_name_with_version(self):

+ 6 - 2
ambari-agent/src/main/python/resource_management/core/providers/package/yumrpm.py

@@ -28,10 +28,14 @@ REMOVE_CMD = "/usr/bin/yum -d 0 -e 0 -y erase %s"
 
 class YumProvider(PackageProvider):
   def install_package(self, name):
-    shell.checked_call(INSTALL_CMD % (name))
+    cmd = INSTALL_CMD % (name)
+    self.log.info("Installing package %s ('%s')", name, cmd)
+    shell.checked_call(cmd)
 
   def upgrade_package(self, name):
     return self.install_package(name)
   
   def remove_package(self, name):
-    shell.checked_call(REMOVE_CMD % (name))    
+    cmd = REMOVE_CMD % (name)
+    self.log.info("Removing package %s ('%s')", name, cmd)
+    shell.checked_call(cmd)    

+ 6 - 2
ambari-agent/src/main/python/resource_management/core/providers/package/zypper.py

@@ -28,10 +28,14 @@ REMOVE_CMD = "/usr/bin/zypper --quiet remove --no-confirm %s"
 
 class ZypperProvider(PackageProvider):
   def install_package(self, name):
-    shell.checked_call(INSTALL_CMD % (name))
+    cmd = INSTALL_CMD % (name)
+    self.log.info("Installing package %s ('%s')", name, cmd)
+    shell.checked_call(cmd)
 
   def upgrade_package(self, name):
     return self.install_package(name)
   
   def remove_package(self, name):
-    shell.checked_call(REMOVE_CMD % (name))
+    cmd = REMOVE_CMD % (name)
+    self.log.info("Removing package %s ('%s')", name, cmd)
+    shell.checked_call(cmd)

+ 1 - 1
ambari-agent/src/main/python/resource_management/core/providers/system.py

@@ -218,7 +218,7 @@ class ExecuteProvider(Provider):
       if os.path.exists(self.resource.creates):
         return
 
-    self.log.info("Executing %s" % self.resource)
+    self.log.debug("Executing %s" % self.resource)
     
     if self.resource.path != []:
       if not self.resource.environment:

+ 6 - 0
ambari-agent/src/main/python/resource_management/core/source.py

@@ -45,6 +45,9 @@ class Source(object):
 
   def __call__(self):
     return self.get_content()
+  
+  def __repr__(self):
+    return self.__class__.__name__+"('"+self.name+"')"
 
 
 class StaticFile(Source):
@@ -123,6 +126,9 @@ else:
     def __init__(self, name, extra_imports=[], **kwargs):
       self.template_env = JinjaEnvironment(loader=FunctionLoader(lambda text: text))
       super(InlineTemplate, self).__init__(name, extra_imports, **kwargs) 
+  
+    def __repr__(self):
+      return "InlineTemplate(...)"
 
 
 class DownloadSource(Source):

+ 3 - 1
ambari-agent/src/main/python/resource_management/libraries/functions/default.py

@@ -23,6 +23,7 @@ Ambari Agent
 __all__ = ["default"]
 import logging
 from resource_management.libraries.script import Script
+from resource_management.libraries.script.config_dictionary import UnknownConfiguration
 
 default_subdict='/configurations/global'
 log = logging.getLogger('resource_management')
@@ -38,7 +39,8 @@ def default(name, default_value):
     if x in curr_dict:
       curr_dict = curr_dict[x]
     else:
-      log.debug("Cannot find configuration: '%s'. Using '%s' value as default" % (name, default_value))
+      if not isinstance(default_value, UnknownConfiguration):
+        log.info("Cannot find configuration: '%s'. Using '%s' value as default" % (name, default_value))
       return default_value
 
   return curr_dict

+ 1 - 1
ambari-agent/src/main/python/resource_management/libraries/providers/xml_config.py

@@ -40,7 +40,7 @@ class XmlConfigProvider(Provider):
   </configuration>''', extra_imports=[time], configurations_dict=self.resource.configurations)
    
   
-    self.log.debug(format("Generating config: {conf_dir}/{filename}"))
+    self.log.info(format("Generating config: {conf_dir}/{filename}"))
     
     with Environment.get_instance_copy() as env:
       File (format("{conf_dir}/{filename}"),

+ 2 - 2
ambari-agent/src/main/python/resource_management/libraries/script/script.py

@@ -63,9 +63,9 @@ class Script(object):
     # set up logging (two separate loggers for stderr and stdout with different loglevels)
     logger = logging.getLogger('resource_management')
     logger.setLevel(logging.DEBUG)
-    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+    formatter = logging.Formatter('%(asctime)s - %(message)s')
     chout = logging.StreamHandler(sys.stdout)
-    chout.setLevel(logging.DEBUG)
+    chout.setLevel(logging.INFO)
     chout.setFormatter(formatter)
     cherr = logging.StreamHandler(sys.stderr)
     cherr.setLevel(logging.ERROR)