From c4199692534010ad8eb4072c7613ceca79663c98 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Tue, 23 Nov 2021 13:25:08 -0500 Subject: [PATCH] Make sure to fire off failure notifications on error where the error is unrelated to Ansible, thus is not caught by the usual methods. --- awx/main/tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index d3ce8f155f..939ca41987 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1542,9 +1542,11 @@ class BaseTask(object): 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])