diff --git a/awx/main/tasks/system.py b/awx/main/tasks/system.py index bca9d16c055f..15c4aa5a620d 100644 --- a/awx/main/tasks/system.py +++ b/awx/main/tasks/system.py @@ -684,8 +684,18 @@ 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}") + try: + receptor_ctl.simple_command(f"work cancel {job.work_unit_id}") + receptor_ctl.simple_command(f"work release {job.work_unit_id}") + except Exception as e: + # force release of work unit. Try/except is required becasue force-release + # try to release the job one time and thne delete it from worklist + logger.error(f"Error on cancel or release {job.work_unit_id} with error {str(e)}.Try Force it...") + try: + receptor_ctl.simple_command(f"work force-release {job.work_unit_id}") + logger.debug(f"{job.log_format} is now released") + except Exception as e: + logger.error(f"Error on force-release {job.work_unit_id} with error {str(e)}. Skip It") administrative_workunit_reaper(receptor_work_list)