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
Fix include loading for handler runs #69459
Conversation
When using the free (or host_pinned) strategy if your playbook includes a tasks, roles and handlers, an error can occur when handlers are run and there are included files to process. In the free.py strategy[0], when included files are run there is an additional check to see if the included file is a role and to process that differently than if it's an included file. [0] https://github.com/ansible/ansible/blob/c8704573396e7480b3e1b33b2ddda2b6325d0d80/lib/ansible/plugins/strategy/free.py#L244-L254 Resolves ansible#69457
b678be2
to
150cdf8
Compare
👍 with the proposed solution. Thanks for fixing that bug Alex! |
At a minimum, this is going to need integration tests to validate what you are fixing, as well as a changelog. Without a reproducer, I'm not sure I fully understand what is being fixed here. Roles cannot be used as handlers. |
This is not about roles being used as handlers but rather output of IncludedFile.process_include_results can be roles. |
I'm still not sure I understand, but I'll await integration tests that include a reproducer. |
I'll try and figure out a reproducer but it seems to be a race condition based on when/how this is called when using the free strategy. |
Right now I have a very complex set of playbooks that hit it at a scale of 13 nodes but not 4, however it is hit consistently on at least 2-3 nodes when deploying my playbooks using an environment of size 13 |
The test
|
I may have an idea what is happening, and if correct, would mean that this fix is insufficient. Both So I am guessing that at least 1 host has made it to processing handlers, and other hosts are still executing normal tasks. As such, As such, while this would fix that situation, it would use We've been talking about adding a new |
Yea sounds like what's happening because with free, the handler would get hit on a different host first while others are doing other tasks |
I think this is triggered because we use meta: flush_handlers in some roles. |
I wonder if this can be addressed by adding logic to the |
Yea this doesn't address the problem. I was sort of able to work around it by treating the flush_handlers task like a regular task when advancing the hosts when running under free by wedging something in around here: https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/strategy/free.py#L192-L194 But I end up with issues in |
I commented over in the original issue, but I have a basic reproducer available @ https://github.com/mwhahaha/ansible-69457 It reproduces with a decent number of nodes like 13 |
#69498 resolves this |
SUMMARY
When using the free (or host_pinned) strategy if your playbook includes
a tasks, roles and handlers, an error can occur when handlers are run
and there are included files to process. In the free.py strategy[0], when
included files are run there is an additional check to see if the
included file is a role and to process that differently than if it's an
included file.
[0]
ansible/lib/ansible/plugins/strategy/free.py
Lines 244 to 254 in c870457
Resolves #69457
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION