fix(deleter): handle non-directory entries in log_root#37716
Open
Akasxh wants to merge 2 commits intocommaai:masterfrom
Open
fix(deleter): handle non-directory entries in log_root#37716Akasxh wants to merge 2 commits intocommaai:masterfrom
Akasxh wants to merge 2 commits intocommaai:masterfrom
Conversation
The deleter crashed with NotADirectoryError when encountering stray files (e.g. tar.gz archives) or symlinks in the log_root directory, because os.listdir() was called unconditionally on every entry. Now checks if an entry is a real directory before attempting to list its contents for lock files. Files and symlinks are deleted directly with os.remove() instead of shutil.rmtree(). Adds tests for: - Stray files in log_root (the original reported bug) - Symlinks (removed without following the target) - Mixed entries (dirs, files, nested dirs, hidden files) - Continued deletion after per-entry errors Fixes commaai#30102
listdir_by_creation() only returns directories, so stray files and symlinks were never considered for deletion. Now collects non-directory entries separately and prioritizes them for cleanup before segment dirs.
Author
|
Note: this PR takes a minimal-diff approach compared to #37642 which refactors into new helper functions. The key differences:
|
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.
Summary
NotADirectoryErrorwhen stray files (e.g.2023-09-23.tar.gz) or symlinks existed inlog_root, becauseos.listdir()was called on every entry unconditionallyos.path.isdir()before listing contents for lock files; files and symlinks are deleted directly withos.remove()Tests
Added 4 new test cases covering the scenarios from the issue:
Test plan
pytest system/loggerd/tests/test_deleter.py -vpasses all existing + new tests/data/media/0/realdata/Fixes #30102