mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 20:20:06 -03:30
Merge pull request #174 from AlanCoding/task_callback_logs
Improve logging for errors in job success/fail hooks
This commit is contained in:
@@ -329,7 +329,7 @@ def handle_work_success(self, result, task_actual):
|
|||||||
try:
|
try:
|
||||||
instance = UnifiedJob.get_instance_by_type(task_actual['type'], task_actual['id'])
|
instance = UnifiedJob.get_instance_by_type(task_actual['type'], task_actual['id'])
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
logger.warning('Missing job `{}` in success callback.'.format(task_actual['id']))
|
logger.warning('Missing {} `{}` in success callback.'.format(task_actual['type'], task_actual['id']))
|
||||||
return
|
return
|
||||||
if not instance:
|
if not instance:
|
||||||
return
|
return
|
||||||
@@ -342,13 +342,16 @@ def handle_work_success(self, result, task_actual):
|
|||||||
|
|
||||||
@task(bind=True, queue='tower', base=LogErrorsTask)
|
@task(bind=True, queue='tower', base=LogErrorsTask)
|
||||||
def handle_work_error(self, task_id, subtasks=None):
|
def handle_work_error(self, task_id, subtasks=None):
|
||||||
print('Executing error task id %s, subtasks: %s' %
|
logger.debug('Executing error task id %s, subtasks: %s' % (str(self.request.id), str(subtasks)))
|
||||||
(str(self.request.id), str(subtasks)))
|
|
||||||
first_instance = None
|
first_instance = None
|
||||||
first_instance_type = ''
|
first_instance_type = ''
|
||||||
if subtasks is not None:
|
if subtasks is not None:
|
||||||
for each_task in subtasks:
|
for each_task in subtasks:
|
||||||
instance = UnifiedJob.get_instance_by_type(each_task['type'], each_task['id'])
|
try:
|
||||||
|
instance = UnifiedJob.get_instance_by_type(each_task['type'], each_task['id'])
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
logger.warning('Missing {} `{}` in success callback.'.format(each_task['type'], task_actual['id']))
|
||||||
|
instance = None
|
||||||
if not instance:
|
if not instance:
|
||||||
# Unknown task type
|
# Unknown task type
|
||||||
logger.warn("Unknown task type: {}".format(each_task['type']))
|
logger.warn("Unknown task type: {}".format(each_task['type']))
|
||||||
|
|||||||
Reference in New Issue
Block a user