-
Notifications
You must be signed in to change notification settings - Fork 9.8k
loggerd: enhance deleter to handle stray files in log root for improved robustness #35245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing to openpilot! In order for us to review your PR as quickly as possible, check the following:
- Convert your PR to a draft unless it's ready to review
- Read the contributing docs
- Before marking as "ready for review", ensure:
- the goal is clearly stated in the description
- all the tests are passing
- the change is something we merge
- include a route or your device' dongle ID if relevant
# delete stray files first | ||
files = [item for item in all_items if os.path.isfile(os.path.join(log_root, item))] | ||
for file in files: | ||
os.remove(os.path.join(log_root, file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
permission error?
all_items = os.listdir(log_root) | ||
|
||
# delete stray files first | ||
files = [item for item in all_items if os.path.isfile(os.path.join(log_root, item))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't handle directories
@@ -115,3 +115,14 @@ def test_no_delete_with_lock_file(self): | |||
self.join_thread() | |||
|
|||
assert f_path.exists(), "File deleted when locked" | |||
|
|||
def test_delete_stray_file_in_log_root(self): | |||
f_path = self.make_file_with_data("", self.f_type, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test should create all sorts of random files and directories to really stress this path
Description
This PR addresses issue #30102, where deleter previously failed to handle non-directory files placed directly under the log root directory (e.g., user-created stray files).
This PR modified
deleter_thread
to include deletion of files directly underPaths.log_root()
, in addition to existing directory cleanup logic.This is a first step — I plan to add more unit tests covering diverse file and directory structures, along with corresponding improvements to
deleter
in follow-up commits.Verification
Added a unit test
test_delete_stray_file_in_log_root
that places a stray file in the log root and asserts it is successfully deleted. Achieved 100% test coverage for the newly added logic.