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

fix loading vars_plugins in roles #82273

Merged
merged 6 commits into from Jan 26, 2024

Conversation

s-hertel
Copy link
Contributor

@s-hertel s-hertel commented Nov 22, 2023

SUMMARY

Fixes #82239

Adding a new role dir to the plugin loader clears the plugin loader cache, but the variable cached_vars_plugin_order in ansible.vars.plugins is never reset, preventing new plugins from being found.

Remove cache in the middle and use the vars plugin loader cache as the load-order. To make this possible, the cache keys now include non-stateless vars plugins (the value is a None, unresolved PluginLoadContext() tuple to be easily distinguished from stateless plugins).

ISSUE TYPE
  • Bugfix Pull Request
ADDITIONAL INFORMATION

use vars_loader as the source of truth by changing it to an ordered dict

ci_complete
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. has_issue needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 22, 2023
@s-hertel s-hertel force-pushed the fix-clearing-vars-plugin-cache branch from 5ebc1e7 to a97f73b Compare November 23, 2023 12:54
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Nov 23, 2023
@s-hertel s-hertel force-pushed the fix-clearing-vars-plugin-cache branch from 0de2af4 to 5b413e5 Compare November 27, 2023 14:31
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Nov 28, 2023
@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 Dec 14, 2023
@s-hertel
Copy link
Contributor Author

s-hertel commented Jan 9, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ansibot ansibot removed 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 Jan 9, 2024
Simplify, comment code
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 10, 2024
lib/ansible/vars/plugins.py Outdated Show resolved Hide resolved
Comment on lines +83 to +85
if vars_loader._paths is None:
# cache has been reset, reload all()
_prime_vars_loader()
Copy link
Contributor Author

@s-hertel s-hertel Jan 16, 2024

Choose a reason for hiding this comment

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

I used vars_loader._paths here as opposed to (for example) vars_loader._search_paths because I'm assuming we don't want to extend OLD_PLUGIN_CACHE_CLEARING to new caches.

I moved this into the vars plugin loader too. <- Actually can't, it duplicates any stateless enabled plugins.

@s-hertel s-hertel force-pushed the fix-clearing-vars-plugin-cache branch from 1697252 to 3711be8 Compare January 16, 2024 18:13
@s-hertel s-hertel merged commit 13e6d84 into ansible:devel Jan 26, 2024
62 checks passed
s-hertel added a commit to s-hertel/ansible that referenced this pull request Jan 26, 2024
* Fix loading legacy vars plugins when the plugin loader cache is reset

* Remove extra cache layer by ensuring vars plugin names are cached (stateless or not) so that the plugin loader cache can double as the load order

(cherry picked from commit 13e6d84)
sivel pushed a commit that referenced this pull request Feb 14, 2024
* Fix loading legacy vars plugins when the plugin loader cache is reset

* Remove extra cache layer by ensuring vars plugin names are cached (stateless or not) so that the plugin loader cache can double as the load order

(cherry picked from commit 13e6d84)
@ansible ansible locked and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. has_issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ansible 2.16 cannot load a vars plugin from role anymore
4 participants