1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Change celery task id in dependent job failure msg

We'll now display a little json that should help the UI in rendering a
link to the dependent job in the job detail screen
This commit is contained in:
Matthew Jones 2015-10-12 13:24:03 -04:00
parent 6e2efd3f8a
commit ae3f5c220e

View File

@ -162,6 +162,7 @@ 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_id = None
first_task_type = ''
first_task_name = ''
if subtasks is not None:
@ -184,13 +185,14 @@ def handle_work_error(self, task_id, subtasks=None):
break
if first_task is None:
first_task = instance
first_task_id = instance.id
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.job_explanation = "Previous Task Failed: %s for %s with celery task id: %s" % \
(first_task_type, first_task_name, task_id)
instance.job_explanation = 'Previous Task Failed: {"task_type": "%s", "task_name": "%s", "task_id": "%s"}' % \
(first_task_type, first_task_name, first_task_id)
instance.save()
instance.socketio_emit_status("failed")