Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass new ansible-runner parameters to reduce number of artifacts we don't need on file system #11472

Merged
merged 3 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions awx/main/tasks/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,11 @@ def final_run_hook(self, instance, status, private_data_dir, fact_modification_t
Hook for any steps to run after job/task is marked as complete.
"""
instance.log_lifecycle("finalize_run")
job_profiling_dir = os.path.join(private_data_dir, 'artifacts/playbook_profiling')
artifact_dir = os.path.join(private_data_dir, 'artifacts', str(self.instance.id))
job_profiling_dir = os.path.join(artifact_dir, 'playbook_profiling')
awx_profiling_dir = '/var/log/tower/playbook_profiling/'
collections_info = os.path.join(private_data_dir, 'artifacts/', 'collections.json')
ansible_version_file = os.path.join(private_data_dir, 'artifacts/', 'ansible_version.txt')
collections_info = os.path.join(artifact_dir, 'collections.json')
ansible_version_file = os.path.join(artifact_dir, 'ansible_version.txt')

if not os.path.exists(awx_profiling_dir):
os.mkdir(awx_profiling_dir)
Expand Down Expand Up @@ -673,6 +674,7 @@ def run(self, pk, **kwargs):
'settings': {
'job_timeout': self.get_instance_timeout(self.instance),
'suppress_ansible_output': True,
'suppress_output_file': True,
},
}

Expand Down Expand Up @@ -1159,7 +1161,7 @@ def final_run_hook(self, job, status, private_data_dir, fact_modification_times)
return
if job.use_fact_cache:
job.finish_job_fact_cache(
os.path.join(private_data_dir, 'artifacts', 'fact_cache'),
os.path.join(private_data_dir, 'artifacts', str(job.id), 'fact_cache'),
fact_modification_times,
)

Expand Down Expand Up @@ -1895,7 +1897,7 @@ def post_run_hook(self, inventory_update, status):
return # nothing to save, step out of the way to allow error reporting

private_data_dir = inventory_update.job_env['AWX_PRIVATE_DATA_DIR']
expected_output = os.path.join(private_data_dir, 'artifacts', 'output.json')
expected_output = os.path.join(private_data_dir, 'artifacts', str(inventory_update.id), 'output.json')
with open(expected_output) as f:
data = json.load(f)

Expand Down
8 changes: 8 additions & 0 deletions awx/main/tasks/receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import concurrent.futures
from enum import Enum
import logging
import os
import shutil
import socket
import sys
import threading
Expand Down Expand Up @@ -330,6 +332,12 @@ def _run_internal(self, receptor_ctl):

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,
Expand Down
5 changes: 4 additions & 1 deletion requirements/requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
aiohttp
ansible-runner==2.1.1
ansiconv==1.0.0 # UPGRADE BLOCKER: from 2013, consider replacing instead of upgrading
asciichartpy
autobahn>=20.12.3 # CVE-2020-35678
Expand Down Expand Up @@ -61,3 +60,7 @@ uwsgitop
wheel
pip==21.2.4 # see UPGRADE BLOCKERs
setuptools==58.2.0 # see UPGRADE BLOCKERs

# Temporarily added to use ansible-runner from git branch, to be removed
# when ansible-runner moves from requirements_git.txt to here
pbr
5 changes: 3 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ aiohttp==3.6.2
# via -r /awx_devel/requirements/requirements.in
aioredis==1.3.1
# via channels-redis
ansible-runner==2.1.1
# via -r /awx_devel/requirements/requirements.in
# via -r /awx_devel/requirements/requirements_git.txt
ansiconv==1.0.0
# via -r /awx_devel/requirements/requirements.in
asciichartpy==1.5.25
Expand Down Expand Up @@ -225,6 +224,8 @@ oauthlib==3.1.0
# social-auth-core
openshift==0.11.0
# via -r /awx_devel/requirements/requirements.in
pbr==5.6.0
# via -r /awx_devel/requirements/requirements.in
pexpect==4.7.0
# via
# -r /awx_devel/requirements/requirements.in
Expand Down
2 changes: 2 additions & 0 deletions requirements/requirements_git.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
git+https://github.com/ansible/system-certifi.git@devel#egg=certifi
# Remove pbr from requirements.in when moving ansible-runner to requirements.in
git+https://github.com/ansible/ansible-runner.git@devel#egg=ansible-runner