mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Merge pull request #7149 from AlanCoding/agressive_canceling
Cancel dependent project updates
This commit is contained in:
commit
834e68ebc9
@ -795,11 +795,14 @@ class BaseTask(Task):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
self.post_run_hook(instance, status, **kwargs)
|
||||
except Exception:
|
||||
logger.exception('Post run hook of unified job {} errored.'.format(instance.pk))
|
||||
instance = self.update_model(pk)
|
||||
if instance.cancel_flag:
|
||||
status = 'canceled'
|
||||
|
||||
self.post_run_hook(instance, status, **kwargs)
|
||||
instance = self.update_model(pk, status=status, result_traceback=tb,
|
||||
output_replacements=output_replacements,
|
||||
**extra_update_fields)
|
||||
@ -1423,16 +1426,17 @@ class RunProjectUpdate(BaseTask):
|
||||
# A failed file update does not block other actions
|
||||
logger.error('Encountered error updating project dependent inventory: {}'.format(e))
|
||||
|
||||
# Stop all dependent inventory updates if project update was canceled
|
||||
# Stop rest of updates if project or inventory update was canceled
|
||||
project_update.refresh_from_db()
|
||||
if project_update.cancel_flag:
|
||||
break
|
||||
# Don't update inventory scm_revision if update was canceled
|
||||
local_inv_update.refresh_from_db()
|
||||
if local_inv_update.cancel_flag:
|
||||
continue
|
||||
inv_src.scm_last_revision = scm_revision
|
||||
inv_src.save(update_fields=['scm_last_revision'])
|
||||
if project_update.cancel_flag or local_inv_update.cancel_flag:
|
||||
if not project_update.cancel_flag:
|
||||
self.update_model(project_update.pk, cancel_flag=True, job_explanation=_(
|
||||
'Dependent inventory update {} was canceled.'.format(local_inv_update.name)))
|
||||
break
|
||||
if local_inv_update.status == 'successful':
|
||||
inv_src.scm_last_revision = scm_revision
|
||||
inv_src.save(update_fields=['scm_last_revision'])
|
||||
|
||||
def release_lock(self, instance):
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user