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
Validate task attributes with first finalized attrs after loop #80476
Validate task attributes with first finalized attrs after loop #80476
Conversation
71a25e0
to
2b46220
Compare
2b46220
to
f74f3bd
Compare
once there's a way to post validate only certain fields, we can use self._task.post_validate() at the end instead of repopulating task fields from the iteration
…e but needs to behave like ignore_errors rather than just using the last loop single out run_once from attrs to limit scope of the change
self._task.no_log = no_log | ||
# NOTE: run_once cannot contain loop vars because it's templated earlier also | ||
# This is saving the post-validated field from the last loop so the strategy can use the templated value post task execution | ||
self._task.run_once = task_fields.get('run_once') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was worried self._task.from_attrs(task_fields)
might cause issues, so I tried to identify all the FieldAttributes potentially affected by this issue. I believe it's limited to the fields action
, run_once
, ignore_unreachable
, ignore_errors
, loop
, and no_log
since these may be used after the looped task is executed.
no_log
is fine, because it's set just above this changeloop
is fine because empty loops == skipped task and the codepath with the issue (template string is always truthy) doesn't occurignore_errors
is fine because the value for the Task is set to False if any of the individual items are False
So I fixed ignore_unreachable
using the same pattern as ignore_errors
, and limited this to just set run_once
and action
.
…le#80476) * Validate task attributes `run_once` and `action` with finalized attrs after individual loop results * Validate task attribute `ignore_unreachable` using individual loop results Once there's a way to post validate only certain fields, we can use self._task.post_validate() instead This replaces the fix introduced in ansible#80051. (cherry picked from commit bd6feeb)
…le#80476) * Validate task attributes `run_once` and `action` with finalized attrs after individual loop results * Validate task attribute `ignore_unreachable` using individual loop results Once there's a way to post validate only certain fields, we can use self._task.post_validate() instead This replaces the fix introduced in ansible#80051. (cherry picked from commit bd6feeb)
… (#80517) * Validate task attributes `run_once` and `action` with finalized attrs after individual loop results * Validate task attribute `ignore_unreachable` using individual loop results Once there's a way to post validate only certain fields, we can use self._task.post_validate() instead This replaces the fix introduced in #80051. (cherry picked from commit bd6feeb)
SUMMARY
Fixing post validating the task itself when getting loop results. Previously we validated a copy of the task per loop item, but never finalized the overall task the strategy uses later.
This is an alternative to the fix in #80051, without breaking inheritance. Omit still does not work as intended, as with many FA (it's a truthy string), but this is a more general problem we should address.
Supersedes #80382 as a stop-gap before #80394 to unbreak inheritance.
ISSUE TYPE
COMPONENT NAME
TE