Merge "Improve log messages from scheduler"

This commit is contained in:
Jenkins 2015-12-08 22:32:19 +00:00 committed by Gerrit Code Review
commit 19d20e131b
2 changed files with 15 additions and 14 deletions

View File

@ -37,11 +37,11 @@ def task_description(task):
The description is used to identify the task when logging its status.
"""
name = task.__name__ if hasattr(task, '__name__') else None
if isinstance(task, types.MethodType):
if name is not None and hasattr(task, '__self__'):
if name is not None and isinstance(task, (types.MethodType,
types.FunctionType)):
if getattr(task, '__self__', None) is not None:
return '%s from %s' % (name, task.__self__)
elif isinstance(task, types.FunctionType):
if name is not None:
else:
return six.text_type(name)
return repr(task)

View File

@ -14,6 +14,7 @@
import collections
import copy
import datetime
import functools
import itertools
import re
@ -909,15 +910,18 @@ class Stack(collections.Mapping):
stack_status = self.COMPLETE
reason = 'Stack %s completed successfully' % action
action_method = action.lower()
# If a local _$action_kwargs function exists, call it to get the
# action specific argument list, otherwise an empty arg list
handle_kwargs = getattr(self,
'_%s_kwargs' % action_method,
lambda x: {})
@functools.wraps(getattr(resource.Resource, action_method))
def resource_action(r):
# Find e.g resource.create and call it
action_l = action.lower()
handle = getattr(r, '%s' % action_l)
handle = getattr(r, action_method)
# If a local _$action_kwargs function exists, call it to get the
# action specific argument list, otherwise an empty arg list
handle_kwargs = getattr(self,
'_%s_kwargs' % action_l, lambda x: {})
return handle(**handle_kwargs(r))
action_task = scheduler.DependencyTaskGroup(
@ -1558,11 +1562,8 @@ class Stack(collections.Mapping):
'Failed stack pre-ops: %s' % six.text_type(e))
return
def destroy_resource(stack_resource):
return stack_resource.destroy()
action_task = scheduler.DependencyTaskGroup(self.dependencies,
destroy_resource,
resource.Resource.destroy,
reverse=True)
try:
scheduler.TaskRunner(action_task)(timeout=self.timeout_secs())