mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 04:17:36 -02:30
Fix some bugs and show more error detail on a current task when a previous task fails
This commit is contained in:
@@ -368,7 +368,7 @@ class Job(CommonTask):
|
|||||||
if is_qs.count():
|
if is_qs.count():
|
||||||
for inventory_source in is_qs:
|
for inventory_source in is_qs:
|
||||||
inventory_update_details = inventory_source.update_signature()
|
inventory_update_details = inventory_source.update_signature()
|
||||||
if not inventory_update:
|
if not inventory_update_details:
|
||||||
# TODO: Set error here
|
# TODO: Set error here
|
||||||
pass
|
pass
|
||||||
else:
|
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(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])))
|
run_tasks.append(task_class().si(self.pk, **opts).set(link_error=handle_work_error.s(subtasks=[thisjob])))
|
||||||
print runnable_tasks
|
print runnable_tasks
|
||||||
res = chain(runnable_tasks)()
|
res = chain(run_tasks)()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class JobHostSummary(BaseModel):
|
class JobHostSummary(BaseModel):
|
||||||
|
|||||||
@@ -44,21 +44,33 @@ logger = logging.getLogger('awx.main.tasks')
|
|||||||
@task(bind=True)
|
@task(bind=True)
|
||||||
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' % (str(self.request.id), str(subtasks)))
|
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:
|
if subtasks is not None:
|
||||||
for each_task in subtasks:
|
for each_task in subtasks:
|
||||||
|
instance_name = ''
|
||||||
if each_task['type'] == 'project_update':
|
if each_task['type'] == 'project_update':
|
||||||
instance = ProjectUpdate.objects.get(id=each_task['id'])
|
instance = ProjectUpdate.objects.get(id=each_task['id'])
|
||||||
|
instance_name = instance.project.name
|
||||||
elif each_task['type'] == 'inventory_update':
|
elif each_task['type'] == 'inventory_update':
|
||||||
instance = InventoryUpdate.objects.get(id=each_task['id'])
|
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 = Job.objects.get(id=each_task['id'])
|
||||||
|
instance_name = instance.job_template.name
|
||||||
else:
|
else:
|
||||||
# Unknown task type
|
# Unknown task type
|
||||||
break
|
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.status = 'failed'
|
||||||
instance.failed = True
|
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()
|
instance.save()
|
||||||
|
|
||||||
class BaseTask(Task):
|
class BaseTask(Task):
|
||||||
|
|||||||
Reference in New Issue
Block a user