Skip to content
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

Merged
merged 11 commits into from
Nov 16, 2023

Conversation

sandstromviktor
Copy link
Contributor

@sandstromviktor sandstromviktor commented Nov 11, 2023

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.

  • This pull request is against develop branch (not applicable for hotfixes)
  • I have included a link to the issue on GitHub or JIRA (if any)
  • I have included migration files (if there are changes to the model classes)
  • I have included, reviewed and executed tests (unit and end2end) to complement my changes
  • I have updated the related documentation (if necessary)
  • I have updated the release notes (releasenotes.md)
  • I have added a reviewer for this pull request
  • I have added myself as an author for this pull request
  • In the case I have modified settings.py, then I have also updated the studio-settings-configmap.yaml file in serve-charts

Further comments

Anything else you think we should know before merging your code!

@sandstromviktor sandstromviktor added the new feature A new feature label Nov 11, 2023
@sandstromviktor sandstromviktor requested a review from a team November 11, 2023 18:32
@sandstromviktor sandstromviktor self-assigned this Nov 11, 2023
apps/tasks.py Outdated
Comment on lines 641 to 644
@app.task
def delete_old_objects():
# Define the time threshold (24 hours ago)
threshold_time = timezone.now() - timezone.timedelta(days=7)
Copy link
Contributor

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 .

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring added

apps/tasks.py Outdated

@app.task
def delete_old_objects():
'''
Copy link
Contributor

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 :))

Copy link
Contributor Author

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!

Copy link
Contributor Author

@sandstromviktor sandstromviktor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed suggestion

@sandstromviktor sandstromviktor merged commit 049f728 into develop Nov 16, 2023
2 checks passed
@sandstromviktor sandstromviktor deleted the feature/remove-develop-apps-after-one-week branch November 16, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants