From cfeedb158e8ce90dc40b583e60d469226894339f Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 31 Jul 2019 17:08:07 -0400 Subject: [PATCH] attempt to properly clean up runner ansible_pi directories --- awx/main/tasks.py | 10 +++++++++- awx/main/tests/unit/test_tasks.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 40ab47940e6b..7f993ad7f431 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -864,9 +864,17 @@ def build_params_process_isolation(self, instance, private_data_dir, cwd): # Help the user out by including the collections path inside the bubblewrap environment if getattr(settings, 'AWX_ANSIBLE_COLLECTIONS_PATHS', []): show_paths.extend(settings.AWX_ANSIBLE_COLLECTIONS_PATHS) + + pi_path = tempfile.mkdtemp( + prefix='ansible_runner_pi_', + dir=settings.AWX_PROOT_BASE_PATH + ) + os.chmod(pi_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) + self.cleanup_paths.append(pi_path) + process_isolation_params = { 'process_isolation': True, - 'process_isolation_path': settings.AWX_PROOT_BASE_PATH, + 'process_isolation_path': pi_path, 'process_isolation_show_paths': show_paths, 'process_isolation_hide_paths': [ settings.AWX_PROOT_BASE_PATH, diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 2b776bd61032..683f965985fe 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -445,7 +445,7 @@ def test_uses_process_isolation(self, settings): process_isolation_params = task.build_params_process_isolation(job, private_data_dir, cwd) assert True is process_isolation_params['process_isolation'] - assert settings.AWX_PROOT_BASE_PATH == process_isolation_params['process_isolation_path'], \ + assert process_isolation_params['process_isolation_path'].startswith(settings.AWX_PROOT_BASE_PATH), \ "Directory where a temp directory will be created for the remapping to take place" assert private_data_dir in process_isolation_params['process_isolation_show_paths'], \ "The per-job private data dir should be in the list of directories the user can see."