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 5d6234ecf6)
This commit is contained in:
Steven Hardy 2015-09-24 18:41:34 +01:00 committed by Steve Baker
parent 49976fb7be
commit 182034904f
3 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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):

View File

@ -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