Skip to content

Commit

Permalink
Make sure to fire off failure notifications on error
Browse files Browse the repository at this point in the history
where the error is unrelated to Ansible, thus is not caught by the
usual methods.
  • Loading branch information
jbradberry committed Nov 23, 2021
1 parent ba324c7 commit c419969
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions awx/main/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,9 +1542,11 @@ def run(self, pk, **kwargs):
status = res.status
rc = res.rc

if status == 'timeout':
self.instance.job_explanation = "Job terminated due to timeout"
status = 'failed'
if status in ('timeout', 'error'):
self.instance.job_explanation = f"Job terminated due to {status}"
if status == 'timeout':
status = 'failed'

extra_update_fields['job_explanation'] = self.instance.job_explanation
# ensure failure notification sends even if playbook_on_stats event is not triggered
handle_success_and_failure_notifications.apply_async([self.instance.job.id])
Expand Down

0 comments on commit c419969

Please sign in to comment.