Closed mrmcmuffinz closed 1 year ago
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the component bot command.
Hi!
Thanks very much for your submission to Ansible. It means a lot to us that you've taken time to contribute. This is working as intended, but we'd be open to someone adding a feature to improve the interface. You could make the mode
parameter conditional to only pass cleanup
when the job is finished.
However, we're absolutely always up for discussion. Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time. If you or anyone else has any further questions, please let us know by using any of the communication methods listed in the page below:
In the future, sometimes starting a discussion on the development list prior to implementing a feature can make getting things included a little easier, but it's not always necessary.
Thank you once again for this and your interest in Ansible!
You could make it work by making the mode
conditional on the results being finished and/or retries max number met
I would say that it is very poorly written then, just because it is expected doesn't make it right. If I'm going to use async in general I should not have to worry about cleanup of any internal files from ansible.
This is working as intended, but we'd be open to someone adding a feature to improve the interface.
Even if this were the case, do you have example code? Or even given my example above a modification/patch demonstrating this behavior? Seriously I'm asking because this isn't really documented well in the docs.
You could make the mode parameter conditional to only pass cleanup when the job is finished.
A bit of feedback from my side would be to provide examples of how to achieve said proposed solution. As you clearly stated I spent time providing a simple use case and example code to illustrate my observed bug. Please show the same courtesy or point me to docs illustrating how to achieve the same. As for using the communications, I went on matrix to ask and didn't really get a response. I have also tried to send emails to the distribution and they get rejected.
If I'm going to use async in general I should not have to worry about cleanup of any internal files from ansible.
That is a requirement for poll: 0
. From https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_async.html:
When running with poll: 0, Ansible will not automatically cleanup the async job cache file. You will need to manually clean this up with the async_status module with mode: cleanup.
The async_status documentation itself is a little vague about how mode: cleanup
works. That could be improved, and the examples could show how to cleanup, something like https://github.com/ansible/ansible/pull/81697.
Even if this were the case, do you have example code? Or even given my example above a modification/patch demonstrating this behavior? Seriously I'm asking because this isn't really documented well in the docs.
For example, a wait
option could be added here https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/action/async_status.py#L24-L29.
A bit of feedback from my side would be to provide examples of how to achieve said proposed solution.
Here you go.
- name: Wait for async job to end and then cleanup
ansible.builtin.async_status:
jid: '{{ sleeper.ansible_job_id }}'
mode: '{{ item }}'
register: job_result
until: job_result.finished or (job_result.erased is defined)
retries: 5
delay: 10
loop:
- 'status'
- 'cleanup'
retries/until doesn't allow access to the register
variable, but it's easy enough with a loop.
Summary
When running an async task with async_status and mode cleanup, cleanup happens but before the async task is complete. This causes the below error
Issue Type
Bug Report
Component Name
ansible
Ansible Version
Configuration
OS / Environment
MAC OS Ventura 13.5.1
Steps to Reproduce
test.yml:
script.sh:
Expected Results
I expect that the cleanup of the async file to happen after the job has completed not before. Example of output that does not have mode set:
Actual Results