From 182034904f7da306c677e77c880a6266b1b5cd50 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Thu, 24 Sep 2015 18:41:34 +0100 Subject: [PATCH] Reduce frequency of logging environment resources Currently we log all template resources every time any API call happens which indirectly creates an Environment object, which results in a lot of duplicate bloat in the heat logs (not even at debug level..) So, instead log all environment resources (e.g those from resource plugins and the global environment) only when we start the service, and log user-provided template resources only when we do the template validation on create/update, for only the root stack, because we pass a derived subset environment down to all children. We also switch to using the string representation of the ResourceInfo objects, as this contains a bit more useful info than the current log format. Change-Id: I20007c1ad6bf8b1479c1d60a5c392b8b9e1c06c4 Closes-Bug: #1499330 (cherry picked from commit 5d6234ecf64650b0eb7bd92eb530e899ff061457) --- heat/engine/environment.py | 13 +++++++++---- heat/engine/resources/__init__.py | 1 + heat/engine/service.py | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/heat/engine/environment.py b/heat/engine/environment.py index bb75923d1b..4b450bf5e0 100644 --- a/heat/engine/environment.py +++ b/heat/engine/environment.py @@ -262,10 +262,6 @@ class ResourceRegistry(object): 'now': str(info.value)} LOG.warn(_LW('Changing %(path)s from %(was)s to %(now)s'), details) - else: - LOG.info(_LI('Registering %(path)s -> %(value)s'), { - 'path': descriptive_path, - 'value': str(info.value)}) if isinstance(info, ClassResourceInfo): if info.value.support_status.status != support.SUPPORTED: @@ -276,6 +272,15 @@ class ResourceRegistry(object): info.user_resource = (self.global_registry is not None) registry[name] = info + def log_resource_info(self, show_all=False, prefix=None): + registry = self._registry + for name in registry: + if show_all or isinstance(registry[name], TemplateResourceInfo): + msg = (_('%(p)s Registered: %(t)s') % + {'p': prefix or '', + 't': six.text_type(registry[name])}) + LOG.info(msg) + def remove_item(self, info): if not isinstance(info, TemplateResourceInfo): return diff --git a/heat/engine/resources/__init__.py b/heat/engine/resources/__init__.py index d5079b7e44..e2bc8086d2 100644 --- a/heat/engine/resources/__init__.py +++ b/heat/engine/resources/__init__.py @@ -60,6 +60,7 @@ def initialise(): global_env = environment.Environment({}, user_env=False) _load_global_environment(global_env) _environment = global_env + global_env.registry.log_resource_info(show_all=True) def _load_global_environment(env): diff --git a/heat/engine/service.py b/heat/engine/service.py index 8834a57943..d91b5a7ae5 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -624,6 +624,9 @@ class EngineService(service.Service): self._validate_deferred_auth_context(cnxt, stack) stack.validate() + # For the root stack print a summary of the TemplateResources loaded + if nested_depth == 0: + env.registry.log_resource_info(prefix=stack_name) return stack @context.request_context