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

handle run_once with omit keyword on linear strategy #80382

Closed
wants to merge 1 commit into from

Conversation

tu1h
Copy link
Contributor

@tu1h tu1h commented Apr 2, 2023

SUMMARY

According to #80051 (comment). And after my verification, run_once template expression with omit keyword will cause failure indeed. Now fix it.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

linear strategy plugin

ADDITIONAL INFORMATION

Signed-off-by: tu1h <lihai.tu@daocloud.io>
@ansibot ansibot added affects_2.15 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. labels Apr 2, 2023
@felixfontein
Copy link
Contributor

I can confirm that this fixes the community.sops integration tests (ref #80051 (comment)).

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 2, 2023
@felixfontein
Copy link
Contributor

/rebuild_failed

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 2, 2023
@s-hertel
Copy link
Contributor

s-hertel commented Apr 3, 2023

I don't think omit ever worked properly for run_once - before #80051 linear used the templated value ( the omit placeholder string, which is truthy) and the base strategy used the template string (also truthy), so it wouldn't have been able to inherit false.

It took me a few minutes looking at the initial patch to realize the key part was the setattr because while linear was already using the templated value, lib/ansible/plugins/strategy/__init__.py was not. free seems to have the same discrepancy: we use the templated value for run_once there but don't set it for lib/ansible/plugins/strategy/__init__.py to use the same value later. I think finalizing the value should be moved to common code that both strategy plugins can call.

Copy link
Contributor

@s-hertel s-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

free should also handle omit properly during templating.

@bcoca
Copy link
Member

bcoca commented Apr 3, 2023

this is why we should always do post_validate as it handles omit correctly (among other things), otherwise we keep needing to recreate all functionality every time we do a partial lookup of the data.

@s-hertel
Copy link
Contributor

s-hertel commented Apr 3, 2023

@bcoca only at this point we don't have the information to template the whole task. Loops vars are undefined, so a module arg using a loop var would cause a traceback if we call task.post_validate(templar=templar) before accessing task.run_once. What do you think about a _post_validate_run_once method we call manually from the strategy plugins? Like s-hertel@59230c0.

@bcoca
Copy link
Member

bcoca commented Apr 4, 2023

Currently get_validated_value is how we "mostly" post_validate a single field, this is still imperfect.

In the end just accessing the field should 'post validate it' and any other FAs it depends on (using the priority value), but that requires some redesign of post validation.

But before going through that .. we might just want to add an optional parameter to post_validate to stop at the FA specified vs looping over all of them (but still ensuring dependencies are validated first), this will probably solve many problems short term over a full redesign.

@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Apr 4, 2023
@bcoca
Copy link
Member

bcoca commented Apr 4, 2023

related #80394, though I'm tempted to just accept this as is while we work on the permanent solution in that PR

@felixfontein
Copy link
Contributor

Merging this soon (and backporting it to stable-2.15) would improve the situation for community.sops, where CI currently is red :) A permanent solution will likely take longer (and might not be backportable, depending on how it looks).

@s-hertel
Copy link
Contributor

s-hertel commented Apr 6, 2023

related #80394, though I'm tempted to just accept this as is...

This should not have been patched piecemeal for linear in the first place, imo. If we want to just patch linear for community.sops to "work" again, I'd be in favor of reinstating the previous behavior, i.e. a template string containing omit is truthy, rather than partially implementing this. My preference would be to revert the initial PR, I think.

@tu1h
Copy link
Contributor Author

tu1h commented Apr 7, 2023

related #80394, though I'm tempted to just accept this as is...

This should not have been patched piecemeal for linear in the first place, imo. If we want to just patch linear for community.sops to "work" again, I'd be in favor of reinstating the previous behavior, i.e. a template string containing omit is truthy, rather than partially implementing this. My preference would be to revert the initial PR, I think.

On the previous behavior, a template string of run_once for linear is always truthy whether it contains "omit". A new design may not be completed quickly, but it is necessary that some known problems can be fixed before then, although it is imperfect. If the problems are indeed tolerated and accepted for us, I have no objection to that.

@s-hertel
Copy link
Contributor

My objection is with the setattr specifically, because it breaks FA inheritance and was inconsistently applied. Either improving the consistency (like s-hertel@59230c0 - I could open that as a PR if time is an issue here), or moving the templating to occur after the getter would be preferable to me (there are several places though, so that gets a little messy).

Most places where we template FA values piecemeal do not modify the FA, so I think reverting might be the best thing to do here rather than play whack-a-mole with inheritance issues.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 10, 2023
@s-hertel
Copy link
Contributor

s-hertel commented Apr 13, 2023

This should be resolved by #80476, backport for 2.15 is #80517.

omit still does not work as intended, but this should be a more general fix applied to all affected FieldAttributes.

@s-hertel s-hertel closed this Apr 13, 2023
@ansible ansible locked and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.15 bug This issue/PR relates to a bug. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants