From 7b880c65520889eeac4f4ffc66aa6984bc6d880d Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 27 Feb 2020 14:12:47 -0500 Subject: [PATCH 1/2] 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: From 5dba49a7bcde68002e18bc4354b0d68d373f075f Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 27 Feb 2020 14:20:36 -0500 Subject: [PATCH 2/2] Lower level of log about skipped project update --- awx/main/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index d76810a465..bd92b6a124 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1809,7 +1809,7 @@ class RunJob(BaseTask): current_revision = git_repo.head.commit.hexsha if desired_revision == current_revision: job_revision = desired_revision - logger.info('Skipping project sync for {} because commit is locally available'.format(job.log_format)) + logger.debug('Skipping project sync for {} because commit is locally available'.format(job.log_format)) else: sync_needs = all_sync_needs except (ValueError, BadGitName):