Repository navigation
fix(volumepath): respect directory boundaries in TopLevelPathList - #2381
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
TopLevelPathList used strings.HasPrefix to decide whether a path is nested under another, which matches on raw string prefixes rather than on path components. Sibling directories that merely share a textual prefix, such as /var/log and /var/logs, were therefore collapsed onto the shorter one: /var/logs was reported as living under /var/log. This feeds the tailer volume-mount generation in the pod webhook and the host tailer, so a file under /var/logs would end up mounted from /var/log and never tailed. Add an isPathPrefix helper that only treats prefix as a parent when the match ends at a path separator (or at the end of the path), and cover the sibling case with a test. AI-assisted; directed, reviewed and tested by the author. Signed-off-by: Amal Saidov <amalsaidov@users.noreply.github.com>
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.
Describe your changes
volumepath.List.TopLevelPathListdecides whether one path is nested underanother with
strings.HasPrefix. That matches on raw string prefixes ratherthan on path components, so two sibling directories that merely share a textual
prefix get collapsed onto the shorter one.
For example, given
/var/logand/var/logs:so
/var/logsis reported as living under/var/logand the two are merged.TopLevelPathListfeeds the tailer volume-mount generation used by the podmutation webhook (
pkg/webhook/podhandler) and the host tailer(
pkg/resources/hosttailer). With the bug, a file under/var/logswould endup mounted from
/var/log, so that path is never mounted and its logs are nottailed.
The fix adds a small
isPathPrefixhelper that only treatsprefixas aparent when the match ends at a path separator (or at the end of the path), and
leaves the existing nesting behaviour (
/var/logunder/var, etc.) unchanged.How to test
go test ./pkg/resources/volumepath/...A new
siblingPathsSharingPrefixcase inTestTopLevelPathListfails before thechange (
/var/logscollapsed to/var/log) and passes after it. The existingTopLevelPathListcases and thepkg/webhook/podhandlertests still pass.Notes
AI-assisted; directed, reviewed and tested by the author.