-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added delete develop-apps task that runs every day a 4 am. #99
Added delete develop-apps task that runs every day a 4 am. #99
Conversation
apps/tasks.py
Outdated
@app.task | ||
def delete_old_objects(): | ||
# Define the time threshold (24 hours ago) | ||
threshold_time = timezone.now() - timezone.timedelta(days=7) |
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.
Seems like a couple of lines of docstrings would be nice
I would also like to suggest making this configurable via settings.py .
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.
Great suggestion. Ill add docstring.
Regarding the settings, i agree but maybe a different PR since this must update the information regarding this plus the charts repo. Agree?
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.
Docstring added
…om:ScilifelabDataCentre/stackn into feature/remove-develop-apps-after-one-week
apps/tasks.py
Outdated
|
||
@app.task | ||
def delete_old_objects(): | ||
''' |
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.
Use "
Black would have fixed it, so don't forget pre-commit hooks :))
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! I've fixed it now!
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.
Fixed suggestion
Description
This PR adds a scheduled job (run by the celery worker) that checks if any app of type "Develop" (i.e., jupyterlab, vscode or rstudio) is older than 7 days. If it is older, it will delete the app (both on the cluster and the database).
The job is run once a day at 4 am.
You can test this by changing the job to interval (set to 6 seconds) and change the threshold in tasks.py to 1 minute. Then deploy a jupyterlab and see that it gets removed after 1 minute.
Checklist
If you're unsure about any of the items below, don't hesitate to ask. We're here to help!
This is simply a reminder of what we are going to look for before merging your code.
Further comments
Anything else you think we should know before merging your code!