ansible-runner icon indicating copy to clipboard operation
ansible-runner copied to clipboard

Clean up artifacts/N/ssh_key_data fifo on failure of containerization

Open john-westcott-iv opened this issue 2 years ago • 2 comments

If we are running in containerization mode we run a command like:

/usr/bin/podman run --rm --tty --interactive --workdir /runner/project -v /tmp/awx_974_6lpq08hx/:/runner/:Z -v /awx_devel/ansible-runner/ansible_runner/display_callback/callback/:/home/runner/.ansible/plugins/callback/:Z --env-file /tmp/awx_974_6lpq08hx/artifacts/974/env.list --quiet --name ansible_runner_974 --user=root --pull=always quay.io/ansible/junk:latest ssh-agent sh -c "trap 'rm -f /runner/artifacts/974/ssh_key_data' EXIT && ssh-add /runner/artifacts/974/ssh_key_data && rm -f /runner/artifacts/974/ssh_key_data && ansible-playbook -u ans1 -i /runner/inventory/hosts -e @/runner/env/extravars find_files.yml" ; rm -f /tmp/awx_974_6lpq08hx/artifacts/974/ssh_key_data

But if the podman command fails (in the case above because the specified container is invalid) the trap is never executed and the artifacts/N/ssh_key-data fifo pip is not cleaned up. Leaving this fifo around can cause downstream issues because a read of the fifo will just hang.

AWX has a work around https://github.com/ansible/awx/blob/3b6cd1828322f8e7c6b0a6824526c6b9604871a2/awx/main/tasks/callback.py#L189-L203 that can be cleaned up once this fixed.

john-westcott-iv avatar Mar 02 '22 16:03 john-westcott-iv