diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 5deabe4f4d..3137b0848d 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -368,7 +368,7 @@ class Job(CommonTask): if is_qs.count(): for inventory_source in is_qs: inventory_update_details = inventory_source.update_signature() - if not inventory_update: + if not inventory_update_details: # TODO: Set error here pass else: @@ -381,7 +381,7 @@ class Job(CommonTask): run_tasks.append(runnable_tasks[idx]['sig'].set(link_error=handle_work_error.s(subtasks=dependent_tasks))) run_tasks.append(task_class().si(self.pk, **opts).set(link_error=handle_work_error.s(subtasks=[thisjob]))) print runnable_tasks - res = chain(runnable_tasks)() + res = chain(run_tasks)() return True class JobHostSummary(BaseModel): diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 04227572f9..482622d235 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -44,21 +44,33 @@ logger = logging.getLogger('awx.main.tasks') @task(bind=True) def handle_work_error(self, task_id, subtasks=None): print('Executing error task id %s, subtasks: %s' % (str(self.request.id), str(subtasks))) + first_task = None + first_task_type = '' + first_task_name = '' if subtasks is not None: for each_task in subtasks: + instance_name = '' if each_task['type'] == 'project_update': instance = ProjectUpdate.objects.get(id=each_task['id']) + instance_name = instance.project.name elif each_task['type'] == 'inventory_update': instance = InventoryUpdate.objects.get(id=each_task['id']) - elif each_task['type': 'job']: + instance_name = instance.inventory_source.inventory.name + elif each_task['type'] == 'job': instance = Job.objects.get(id=each_task['id']) + instance_name = instance.job_template.name else: # Unknown task type break - if instance.celery_task_id != instance.celery_task_id: + if first_task is None: + first_task = instance + first_task_type = each_task['type'] + first_task_name = instance_name + if instance.celery_task_id != task_id: instance.status = 'failed' instance.failed = True - instance.result_traceback = "Previous Task Failed: %s" % str(subtasks) + instance.result_traceback = "Previous Task Failed: %s for %s with celery task id: %s" % \ + (first_task_type, first_task_name, task_id) instance.save() class BaseTask(Task):