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 authored and TinLe committed Jan 21, 2022
1 parent c3084e8 commit 9872757
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 @@ -1543,9 +1543,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 9872757

Please sign in to comment.