Conversation
This makes it so a loaded matcher doesn't have to load another instance of the loader itself and can instead reuse the existing matchers that are already loaded. This should speed up many matcher operations considerably. Signed-off-by: Joe Groocock <jgroocock@cloudflare.com>
Add changelog entry for PR saltstack#64607 and replace the now-obsolete test_matchers_from_context test (which tested __context__ caching) with tests that verify __matchers__ is injected and never causes recursive salt.loader.matchers() calls.
…er for __matchers__
|
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here's some information that may help as you continue your Salt journey. There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
What does this PR do?
This PR provides a significant performance optimization for matcher operations and resolves critical bugs related to context propagation within compound and nodegroup matchers.
This PR replaces and supersedes the following:
Performance Optimization:
__matchers__magic dunder and updates the loader to support it. This allows matchers to access the pre-loaded matcher registry via a high-speedconfirm_topto leverage this new__matchers__dunder, ensuring the existing matcher registry is reused.Bug Fixes (Context Propagation):
salt/matchers/compound_match.pyandsalt/matchers/nodegroup_match.pyto explicitly passoptsandminion_idthrough the matching chain. This ensures that engines requiring specific execution context (such as pillar data or minion identity) receive the correct parameters.Benchmark comparison:
What issues does this PR fix or reference?
Fixes: #61950
Previous Behavior
optsandminion_idcontext when evaluating nested or sub-matchers, leading to incorrect matching results in environments relying on dynamic pillar or grain data.New Behavior
__matchers__dunder provides immediate access to the loaded matchers, caching the registry on the first pass and eliminating redundant I/O and computation.optsandminion_idare now consistently propagated through all matcher engines, ensuring predictable and accurate matching behavior.Merge requirements satisfied?
Commits signed with GPG?
Yes