From 2609ee5ed0a7b7bbdef4a5ea648297bf527c844d Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Tue, 18 Jan 2022 14:51:40 -0500 Subject: [PATCH] Delete artifact dir after transmit phase is finished --- awx/main/tasks/receptor.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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,