1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 17:55:10 +03:00

call 'work cancel' on inactive controller jobs

This commit is contained in:
Jim Ladd 2021-09-30 17:05:21 -07:00
parent 0b66b61dd6
commit 815a45cf2f

View File

@ -603,6 +603,12 @@ def awx_receptor_workunit_reaper():
As such, this periodic task will obtain a list of all receptor work units, and find which ones
belong to AWX jobs that are in a completed state (status is canceled, error, or succeeded).
This task will call "work release" on each of these work units to clean up the files on disk.
Note that when we call "work release" on a work unit that actually represents remote work
both the local and remote work units are cleaned up.
Since we are cleaning up jobs that controller considers to be inactive, we take the added
precaution of calling "work cancel" in case the work unit is still active.
"""
if not settings.RECEPTOR_RELEASE_WORK:
return
@ -614,6 +620,7 @@ def awx_receptor_workunit_reaper():
jobs_with_unreleased_receptor_units = UnifiedJob.objects.filter(work_unit_id__in=unit_ids).exclude(status__in=ACTIVE_STATES)
for job in jobs_with_unreleased_receptor_units:
logger.debug(f"{job.log_format} is not active, reaping receptor work unit {job.work_unit_id}")
receptor_ctl.simple_command(f"work cancel {job.work_unit_id}")
receptor_ctl.simple_command(f"work release {job.work_unit_id}")