-
Notifications
You must be signed in to change notification settings - Fork 37
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
Delete expired files with management command #518
Delete expired files with management command #518
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.
|
||
|
||
@pytest.mark.parametrize( | ||
("mock_datetime", "should_delete"), |
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.
Tiny nitpick - I wouldn't call this a mock really.
|
||
try: | ||
core_api.delete_file(file.core_file_uuid, file.user) | ||
file.delete_from_s3() |
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 could be part of the File.delete
method 🤔 , probably doesnt add much and just over-complicates things?
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.
We currently have a File.delete that actually deletes the file, whereas this just removes the file contents but keeps a record of the File in Django (for auditing processes). I think this was a product decision a few weeks ago.
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.
super clear, as always!
Context
Now that we have a way to track when files were last used, we can remove them with a management command. There is still some discussion about how this command will be triggered, and this might change over time.
There is a future change to come that will also remove expired Chats and ChatHistory.
Changes proposed in this pull request
Creates a management command that checks for files past their expiry date and removes their chunks from elastic storage, deleted the file contents from S3 and then transitions them to 'deleted' in Django (so we keep a record).
If there is an error in the elastic or S3 deletion, the file is marked as 'errored' in Django (a new status type). Errors are logged. We need to develop a process of reviewing and handling batches of errors.
Other changes
django_app/tests_playwright/pages.py
Guidance to review
Do you agree with the approach? Is there any other error handling needed? What else can we do around files that are partially deleted?
Relevant links
https://technologyprogramme.atlassian.net/browse/REDBOX-234
Things to check