From 1eddd29098da08904760577d54f296a7a99866f6 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 3 Aug 2017 11:37:59 -0400 Subject: [PATCH] Improve logging for errors in job success/fail hooks This sets the instance=None and continues with dependent subtask processing in handle_work_error, whereas execution had been getting halted by a DNE error. --- awx/main/tasks.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 6f7129b514..73e3f4d5b4 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -329,7 +329,7 @@ def handle_work_success(self, result, task_actual): try: instance = UnifiedJob.get_instance_by_type(task_actual['type'], task_actual['id']) 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 if not instance: return @@ -342,13 +342,16 @@ def handle_work_success(self, result, task_actual): @task(bind=True, queue='tower', base=LogErrorsTask) def handle_work_error(self, task_id, subtasks=None): - print('Executing error task id %s, subtasks: %s' % - (str(self.request.id), str(subtasks))) + logger.debug('Executing error task id %s, subtasks: %s' % (str(self.request.id), str(subtasks))) first_instance = None first_instance_type = '' if subtasks is not None: 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: # Unknown task type logger.warn("Unknown task type: {}".format(each_task['type']))