[3006.x] Fix salt-ssh Jinja TemplateNotFound on map.jinja imports#69596
Open
dwoz wants to merge 1 commit into
Open
[3006.x] Fix salt-ssh Jinja TemplateNotFound on map.jinja imports#69596dwoz wants to merge 1 commit into
dwoz wants to merge 1 commit into
Conversation
Backport of 481bd7a (3007.x/3008.x) to 3006.x. SaltCacheLoader built its searchpath from opts["cachedir"]. Under salt-ssh, opts["cachedir"] points at the thin minion's remote path on the SSH target, while the master-side fileclient caches requested files under opts["_caller_cachedir"] (the master's cachedir). A Jinja import like {% from "formula/map.jinja" import x with context %} therefore raised TemplateNotFound: the file existed in the master cache, but the loader looked in the (empty) thin path. Prefer opts["_caller_cachedir"] when present so Jinja imports resolve against the master's cache dir. opts["_caller_cachedir"] is already populated on 3006.x by salt/client/ssh/__init__.py; only the consumer was missing. Only the salt/utils/jinja.py hunk from 481bd7a is backported; the test-timeout hunks in that commit are 3007.x/3008.x-only. Fixes: saltstack#31531
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?
Backports the
salt/utils/jinja.pyhunk from commit481bd7a6a72to3006.x.SaltCacheLoaderbuilt its searchpath fromopts["cachedir"]. Undersalt-ssh,
opts["cachedir"]points at the thin minion's remote path on theSSH target, while the master-side fileclient caches requested files under
opts["_caller_cachedir"](the master's cachedir). A Jinja import like{% from "formula/map.jinja" import x with context %}therefore raisedTemplateNotFound: the file existed in the master cache, but the loaderlooked in the (empty) thin path.
This change makes
SaltCacheLoader.__init__preferopts["_caller_cachedir"]when present, so Jinja imports resolve againstthe master's cache dir. The
_caller_cachediropt is already populated on3006.x by
salt/client/ssh/__init__.py(lines ~1206-1209) — only theconsumer side was missing.
What issues does this PR fix or reference?
Fixes: #31531
Background
#31531was opened in 2016 and closed on 2026-06-29 citing PR #65517, butthat PR's body says "Helps with: 31531" (not "Fixes") and does not patch
SaltCacheLoader.searchpath. The actual fix is commit481bd7a6a72(Apr2026), shipped in v3007.14 and v3008.0+. That commit was never backported
to 3006.x, so the bug still reproduces there.
Library-level repro on each branch (constructing
SaltCacheLoaderwithopts mimicking the salt-ssh master-side wrapper call):
TemplateNotFound: jinjatest/map.jinja481bd7a6a72)481bd7a6a72)481bd7a6a72)Why only the jinja.py hunk?
Commit
481bd7a6a72also restored@pytest.mark.timeout(300)markers onsome salt-ssh integration tests and bumped the
salt_ssh_clifactorytimeout in
tests/pytests/integration/conftest.pyfrom 180s to 300s.Those hunks address 3007.x/3008.x-specific test regressions from a
parallel SSH ThreadPool revert and have no analogue on 3006.x — pulling
them in would be drive-by noise and would not apply cleanly. Only the
single 5-line
SaltCacheLoader.__init__change is relevant here.Regression test
tests/pytests/unit/utils/jinja/test_salt_cache_loader.py::test_searchpath_uses_caller_cachedirasserts that when
opts["_caller_cachedir"]is set the loader'ssearchpathis built from it instead ofopts["cachedir"]. Verifiedlocally: test FAILS without the patch, PASSES with it. All 19 tests in
test_salt_cache_loader.pypass.Merge requirements satisfied?
changelog/31531.fixed.md)Commits signed with GPG?
Yes