From 1ea3c564df167c481684c119c3dc37eadeb05591 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Tue, 19 Jul 2022 16:18:45 -0400 Subject: [PATCH] Apply a failed status if cancel_flag is not set --- awx/main/tasks/jobs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/main/tasks/jobs.py b/awx/main/tasks/jobs.py index 94ce454b44..aeba4cc254 100644 --- a/awx/main/tasks/jobs.py +++ b/awx/main/tasks/jobs.py @@ -608,12 +608,18 @@ class BaseTask(object): status = 'failed' elif status == 'canceled': self.instance = self.update_model(pk) - if (getattr(self.instance, 'cancel_flag', False) is False) and signal_callback(): - # MERGE: prefer devel over this with runner_callback.delay_update() + cancel_flag_value = getattr(self.instance, 'cancel_flag', False) + if (cancel_flag_value is False) and signal_callback(): + # MERGE: prefer devel over this with runner_callback.delay_update(), and for elif case too job_explanation = "Task was canceled due to receiving a shutdown signal." self.instance.job_explanation = self.instance.job_explanation or job_explanation extra_update_fields['job_explanation'] = self.instance.job_explanation status = 'failed' + elif cancel_flag_value is False: + job_explanation = "The running ansible process received a shutdown signal." + self.instance.job_explanation = self.instance.job_explanation or job_explanation + extra_update_fields['job_explanation'] = self.instance.job_explanation + status = 'failed' except ReceptorNodeNotFound as exc: self.runner_callback.delay_update(job_explanation=str(exc)) except Exception: