Delete artifact dir after transmit phase is finished

This commit is contained in:
Alan Rominger
2022-01-18 14:51:40 -05:00
parent 8fac1c18c8
commit 2609ee5ed0

View File

@@ -4,6 +4,8 @@ from collections import namedtuple
import concurrent.futures import concurrent.futures
from enum import Enum from enum import Enum
import logging import logging
import os
import shutil
import socket import socket
import sys import sys
import threading import threading
@@ -330,6 +332,12 @@ class AWXReceptorJob:
transmitter_thread.join() 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) 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. # Both "processor" and "cancel_watcher" are spawned in separate threads.
# We wait for the first one to return. If cancel_watcher returns first, # We wait for the first one to return. If cancel_watcher returns first,