1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Cancel jobs if they were deleted in the database

This commit is contained in:
AlanCoding 2020-02-27 14:12:47 -05:00
parent e096ad18cb
commit 7b880c6552
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B

View File

@ -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: