From 85ec83c3fd97490a1f7d7384cda7c8903d0ec547 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Mon, 28 Mar 2022 10:52:09 -0400 Subject: [PATCH] Minor tweaks to ansible-runner cleanup task arguments --- awx/main/models/ha.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/awx/main/models/ha.py b/awx/main/models/ha.py index 5200f99d3e..763a24c5b8 100644 --- a/awx/main/models/ha.py +++ b/awx/main/models/ha.py @@ -186,12 +186,16 @@ class Instance(HasPolicyEditsMixin, BaseModel): returns a dict that is passed to the python interface for the runner method corresponding to that command any kwargs will override that key=value combination in the returned dict """ - vargs = dict() + vargs = dict(grace_period=60) # grace period of 60 minutes, need to set because CLI default will not take effect if settings.AWX_CLEANUP_PATHS: vargs['file_pattern'] = os.path.join(settings.AWX_ISOLATION_BASE_PATH, JOB_FOLDER_PREFIX % '*') + '*' vargs.update(kwargs) if 'exclude_strings' not in vargs and vargs.get('file_pattern'): - active_pks = list(UnifiedJob.objects.filter(execution_node=self.hostname, status__in=('running', 'waiting')).values_list('pk', flat=True)) + active_pks = list( + UnifiedJob.objects.filter( + (models.Q(execution_node=self.hostname) | models.Q(controller_node=self.hostname)) & models.Q(status__in=('running', 'waiting')) + ).values_list('pk', flat=True) + ) if active_pks: vargs['exclude_strings'] = [JOB_FOLDER_PREFIX % job_id for job_id in active_pks] if 'remove_images' in vargs or 'image_prune' in vargs: