Repository navigation
Fix pillarenv targeting with isolated pillar compilation caches - #70467
Merged
dwoz merged 6 commits intoNov 24, 2026
Merged
Conversation
twangboy
previously approved these changes
Nov 5, 2026
twangboy
requested changes
Nov 12, 2026
twangboy
previously approved these changes
Nov 17, 2026
…etches The previous commit wrote the minion data cache snapshot from every _pillar request, so one-off queries (pillar.items pillarenv=prod) and requests with a pillar override replaced what -I/-J match against, including for minions that were not affected by the original bug. RemotePillar and AsyncRemotePillar now send a "snapshot" field. The minion sets it on its own regular fetches (startup, refresh_pillar, proxy startup, highstate without an override); one-off callers leave it off. The master refreshes the snapshot only when the field is set and no pillar_override is present. Minions that predate the field keep the old behavior unless they send an override. pillar.show_pillar_cache and pillar.clear_pillar_cache now require pillar_cache, since they only manage the compilation cache.
…larenv state.apply pillarenv=prod fetches pillar through the same request as a regular highstate, so the master stored the prod result for a minion that keeps using its configured pillarenv. get_sls_opts now flags opts when the run's pillarenv differs from the minion config (explicit kwarg, localconfig or pillarenv_from_saltenv), and State._gather_pillar sends no snapshot for such runs. A highstate with the configured pillarenv and no pillar override still refreshes it.
Integration tests start a master with pillar_cache and a minion configured with pillarenv: dev, and check -I/-J targeting after a regular refresh, after one-off pillarenv and pillar override queries, and after state.apply with another pillarenv. They also check that a regular state.apply restores the targeting data and that compiled pillars of different environments stay separate. Unit tests cover the snapshot decision in all three _pillar handlers, the flag sent by the minion refresh, and when get_pillar uses PillarCache.
pylint 3.1.1 on Python 3.10 hit a RecursionError while inferring the operand of one comparison in test_targeting_cache.py. Compare the cache value directly, like the other assertions in the file.
Keep the original opening line and describe the new cache layout: compiled pillars live in the pillar_compile bank, keyed by minion id and pillarenv, apart from the pillar snapshot that targeting reads.
dwoz
approved these changes
Nov 24, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fix pillar targeting (
-I,-J) for minions that use apillarenv, including whenpillar_cacheis enabled.Before,
PillarCachestored the compiled pillar under<id>:<pillarenv>, but targeting reads<id>, so these minions never matched. Writing the environment result into<id>would also overwrite the compile cache used by requests without a pillarenv.The two caches are now separate:
pillar_compilebank, usingpillar.cache_driverwhen configured andpillar_cache_ttl. Only used whenpillar_cacheis on.pillar/<id>in the default cache backend. The_pillarhandlers (sync, async, RemoteFuncs) write it, like grains, including on compile cache hits.Only a minion's regular pillar fetch updates the targeting data, because only that fetch replaces the pillar the minion holds. The minion marks those requests with a new
snapshotfield: startup,saltutil.refresh_pillar, proxy startup, andstate.applywith the configured pillarenv and no pillar override. These do not update it:pillar.items pillarenv=prodpillar_overridestate.apply pillarenv=prod(get_sls_optsflags runs whose pillarenv differs from the minion config)pillar.show_pillar, runner queries)Minions that do not send the field keep the old behavior, except that a request with
pillar_overridenever updates the targeting data.get_pillarreturnsPillarCacheonly whenpillar_cacheis on.pillar.show_pillar_cacheandpillar.clear_pillar_cachenow requirepillar_cache, since they only handle the compile cache.Upgrade notes
saltutil.refresh_pillar(or restart the minions). Until then-I/-Jstill misses minions that use apillarenv.pillar_cache: Truethe compile cache starts empty, so each minion/environment is compiled again on its next request. Refreshing many minions at once briefly raises the master load.<id>:<pillarenv>files in thepillarbank are no longer used. They are not deleted.pillar.clear_pillar_cacheclears compile entries;cache.clear_pillarclears targeting data. The next regular pillar fetch of a minion restores it, even on a compile cache hit.snapshotfield, so a one-offpillarenvquery from them still updates the targeting data.Risks
cache.clear_pillar. Older versions read this data as a compile cache.Testing
snapshotflag,get_sls_opts,get_pillarand the runners.tests/pytests/integration/pillar/test_pillarenv_targeting.py) with a real master (pillar_cache: True) and a minion withpillarenv: dev: 8 passed locally. All 8 fail without this change.test_minion_manager_async_stopandtest_minion_manager_destroy_closes_event_publisherfail locally on the base branch as well.filelockis not available on my package mirror). pylint on the changed files is clean.Refs #69599