Fix minionfs raising when the minions cache dir is absent#69695
Open
ggiesen wants to merge 3 commits into
Open
Fix minionfs raising when the minions cache dir is absent#69695ggiesen wants to merge 3 commits into
ggiesen wants to merge 3 commits into
Conversation
Under the salt-ssh shim the master cachedir is a fresh temp dir with no 'minions' subdirectory, so file_list and dir_list called os.listdir(minions_cache_dir) on a non-existent path and raised FileNotFoundError, killing state.highstate. Guard the listdir calls by returning an empty list when the minions cache directory does not exist. Fixes saltstack#50351
…cache dir The direct tests call minionfs.file_list and minionfs.dir_list with the exact load shape production sends (fileclient always includes a prefix and cmd key alongside saltenv), using a non-empty prefix since the prefix handling sits below the os.listdir() call that used to raise when the cache dir was absent. The inverse tests guard against overcorrection: with an existing, populated minions cache dir, both functions must still return the pushed files and directories rather than short-circuiting to an empty list.
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?
salt/fileserver/minionfs.py called os.listdir(minions_cache_dir) unguarded in file_list (line 241) and dir_list (lines 317/337); under the salt-ssh shim the master cachedir is a fresh temp dir with no 'minions' subdir, so both raised FileNotFoundError and killed state.highstate. Fix guards each function: if the minions cache directory does not exist, log.debug and return []. Verified against the bug: with the guard removed both functions raise FileNotFoundError, and with it they return [] (shadow-import of the worktree salt confirmed, salt.file inside the worktree).
What issues does this PR fix or reference?
Fixes #50351
Previous Behavior
See #50351.
New Behavior
Fix minionfs raising when the minions cache dir is absent. Validated by a unit test proven to fail on unpatched 3006.x and pass with the fix (confirmed by adversarial review).
Merge requirements satisfied?
Commits signed with GPG?
No