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

Templating: make sure only one variable results are cached #67429

Merged
merged 4 commits into from Feb 19, 2020

Conversation

felixfontein
Copy link
Contributor

SUMMARY

Currently, it looks like all jinja2 templating results are cached, even though a comment says # we only cache in the case where we have a single variable name, to make sure we're not putting things which may otherwise be dynamic in the cache (filters, lookups, etc.). This causes dynamic lookup results to be cached, which can be seen in #34144 and @resmo's example from IRC.

Fixes #34144

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/template/init.py

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Feb 14, 2020
@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. core_review In order to be merged, this PR must follow the core review workflow. and removed small_patch needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 14, 2020
Copy link
Contributor

@resmo resmo left a comment

Choose a reason for hiding this comment

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

This solve my issue.

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

@felixfontein , :) what about covering the issue case by adding tests somewhere. Probably to test/integration/targets/templating_lookups/template_lookups/ would be ok

@s-hertel s-hertel merged commit c520d70 into ansible:devel Feb 19, 2020
@s-hertel
Copy link
Contributor

Thanks, @felixfontein!

@felixfontein felixfontein deleted the fix-jinja2-caching branch February 20, 2020 06:00
@felixfontein
Copy link
Contributor Author

@Andersson007 @s-hertel thanks a lot for reviewing and merging!

@felixfontein
Copy link
Contributor Author

and I forgot @resmo, thanks for reviewing as well!

@felixfontein felixfontein changed the title Tempating: make sure only one variable results are cached Templating: make sure only one variable results are cached Feb 20, 2020
felixfontein added a commit to felixfontein/ansible that referenced this pull request Feb 20, 2020
…7429)

* Make sure only one variable results are cached.

* Add changelog.

* Add test.

(cherry picked from commit c520d70)
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Feb 20, 2020
mattclay pushed a commit that referenced this pull request Mar 2, 2020
* Make sure only one variable results are cached.

* Add changelog.

* Add test.

(cherry picked from commit c520d70)
@ansible ansible locked and limited conversation to collaborators Mar 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

two random password lookups in same task return same value
6 participants