From 7b880c65520889eeac4f4ffc66aa6984bc6d880d Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 27 Feb 2020 14:12:47 -0500 Subject: [PATCH] Cancel jobs if they were deleted in the database --- awx/main/tasks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 5f98684e3b..d76810a465 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1180,7 +1180,11 @@ class BaseTask(object): ''' Ansible runner callback to tell the job when/if it is canceled ''' - self.instance = self.update_model(self.instance.pk) + unified_job_id = self.instance.pk + self.instance = self.update_model(unified_job_id) + if not self.instance: + logger.error('unified job {} was deleted while running, canceling'.format(unified_job_id)) + return True if self.instance.cancel_flag or self.instance.status == 'canceled': cancel_wait = (now() - self.instance.modified).seconds if self.instance.modified else 0 if cancel_wait > 5: