Fix infinite recursion in etcd cache _walk on empty folders#69235
Open
ggiesen wants to merge 1 commit into
Open
Fix infinite recursion in etcd cache _walk on empty folders#69235ggiesen wants to merge 1 commit into
ggiesen wants to merge 1 commit into
Conversation
etcd reports an empty folder as a child of itself, so _walk() recursed on the
same key until it exhausted the recursion limit and raised a SaltCacheError
("maximum recursion depth exceeded"). Stop the walk when a child's key matches
the folder being walked.
Adds a unit test suite for salt.cache.etcd_cache (previously untested),
covering __virtual__, _init_client, store, fetch, flush, _walk (including the
empty-folder regression), ls, contains, and updated.
Fixes saltstack#57377
4090b8c to
17ece9b
Compare
Contributor
Author
|
Re-targeted to 3006.x (was master): this is a bug fix and 3006.x is the oldest supported branch that contains the affected |
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?
Fixes a
SaltCacheError("maximum recursion depth exceeded") raised by theetcd data cache when a cache bank contains an empty folder.
etcd reports an empty folder as a child of itself, so
_walk()insalt/cache/etcd_cache.pycalled_walk()again on the same key and recurseduntil it hit Python's recursion limit. The walk now stops when a child's key
matches the folder being walked.
What issues does this PR fix or reference?
Fixes #57377
Previous Behavior
Walking a cache bank that contained an empty folder (e.g. via
cache.ls)raised
SaltCacheError: maximum recursion depth exceeded while calling a Python object.New Behavior
The empty folder is detected and skipped, and the walk returns the keys found
without error.
Tests
salt.cache.etcd_cachehad no unit tests, so this adds a suite covering__virtual__,_init_client,store,fetch,flush,_walk(including theempty-folder regression),
ls,contains, andupdated.Merge requirements satisfied?
Commits signed with GPG?
No