diff --git a/awx/main/tasks/receptor.py b/awx/main/tasks/receptor.py index 0a68800a4d..91151bf3e2 100644 --- a/awx/main/tasks/receptor.py +++ b/awx/main/tasks/receptor.py @@ -4,6 +4,8 @@ from collections import namedtuple import concurrent.futures from enum import Enum import logging +import os +import shutil import socket import sys import threading @@ -330,6 +332,12 @@ class AWXReceptorJob: transmitter_thread.join() + # Artifacts are an output, but sometimes they are an input as well + # this is the case with fact cache, where clearing facts deletes a file, and this must be captured + artifact_dir = os.path.join(self.runner_params['private_data_dir'], 'artifacts') + if os.path.exists(artifact_dir): + shutil.rmtree(artifact_dir) + resultsock, resultfile = receptor_ctl.get_work_results(self.unit_id, return_socket=True, return_sockfile=True) # Both "processor" and "cancel_watcher" are spawned in separate threads. # We wait for the first one to return. If cancel_watcher returns first,