-
Notifications
You must be signed in to change notification settings - Fork 473
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
[Storage cleaner] Improve handling of temp directories and files #396
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.
LGTM, just one suggestion
scripts/storage_cleaner.py
Outdated
@@ -729,6 +733,11 @@ def delete_bad_runs(run_paths: List[str], config: DeleteBadRunsConfig): | |||
log.info("Starting to check if run %s should be deleted", run_path) | |||
_delete_if_bad_run(storage, run_path, config) | |||
|
|||
# Delete temp dir after each run to avoid memory bloat |
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.
# Delete temp dir after each run to avoid memory bloat | |
# Delete temp dir after each run to avoid storage bloat |
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.
scripts/storage_cleaner.py
Outdated
if Path(temp_dir).is_dir(): | ||
log.info("Deleting temp dir %s", temp_dir) | ||
shutil.rmtree(temp_dir) |
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 should probably run even if the cleaning op fails, so you might want to add a try: ... finally: ...
block.
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.
The current implementation has a few issues with respect to temp directories and files. Below I list the issues and their corresponding fixes in this PR.
Operations do not delete all the temp content (e.g. unarchived directories) added to the user-provided temp directory.
Handle temporary directory creation and completion in
perform_operation
, which is shared by all operations.Bad run deletion can take several runs as input, so the number of uncleaned artifacts can easily grow.
Added temp directory cleanup after each run.
The unsharding temp directory is not under the user-provided temp directory.
Changed unsharding temp directory creation to fix this.
The majority of the additions/deletions were caused from moving
perform_operation
down the file (77c648a).