-
Notifications
You must be signed in to change notification settings - Fork 32
♻️ web-server: Upgrade GC periodic tasks to new servicelib.background_task
#7970
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
♻️ web-server: Upgrade GC periodic tasks to new servicelib.background_task
#7970
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7970 +/- ##
==========================================
+ Coverage 87.61% 87.76% +0.15%
==========================================
Files 1804 1424 -380
Lines 68935 59171 -9764
Branches 1231 627 -604
==========================================
- Hits 60400 51934 -8466
+ Misses 8179 7026 -1153
+ Partials 356 211 -145
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
ba8a7c6 to
f31912f
Compare
servicelib.background_task
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.
Pull Request Overview
This PR upgrades the garbage collector’s periodic background tasks by refactoring the task creation and management logic to use the new servicelib.background_task utilities. Key changes include:
- Replacing the old run_background_task function with create_background_task_for_garbage_collection throughout the garbage collector.
- Updating the tests and patch targets to align with the new background task pattern and redis-based exclusive periodic decorators.
- Refactoring related task modules (_tasks_users, _tasks_trash, _tasks_api_keys) to use the new setup_periodic_task utility.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| services/web/server/tests/unit/isolated/test_garbage_collector_core.py | Updated model example retrieval method. |
| services/web/server/tests/integration/01/test_garbage_collection.py | Patching and status code changes to use new task creation function and servicelib.aiohttp status constants. |
| services/web/server/src/simcore_service_webserver/garbage_collector/plugin.py | Adjusted cleanup_ctx registration with the new background task creator. |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_utils.py | Introduced a generic setup_periodic_task utility for background tasks. |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_users.py | Updated the expired users task with the exclusive_periodic decorator and refactored task creation. |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_trash.py | Refactored pruning task to use setup_periodic_task and exclusive_periodic. |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_core.py | Migrated the garbage collection loop to the setup_periodic_task framework with exclusive_periodic. |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_api_keys.py | Updated API keys pruning task with exclusive_periodic and refactored task management. |
| packages/service-library/src/servicelib/background_task_utils.py | Minor update to use f-string for error messaging. |
| packages/service-library/src/servicelib/background_task.py | Updated docstring and parameter formatting for clarity. |
Comments suppressed due to low confidence (2)
services/web/server/tests/integration/01/test_garbage_collection.py:203
- Ensure that the updated patch target 'create_background_task_for_garbage_collection' properly replaces the old 'run_background_task' and that the tests accurately reflect the new background task lifecycle.
"simcore_service_webserver.garbage_collector.plugin._tasks_core.create_background_task_for_garbage_collection",
services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_users.py:70
- [nitpick] Consider renaming 'create_background_task_for_trial_accounts' to better indicate that the task updates expired users if that is its primary function.
def create_background_task_for_trial_accounts(wait_s: float) -> CleanupContextFunc:
services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_core.py
Show resolved
Hide resolved
…th exclusive task handling
…utility for cleaner task setup and teardown
991a087 to
de52738
Compare
sanderegg
left a comment
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
services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_utils.py
Outdated
Show resolved
Hide resolved
services/web/server/tests/integration/01/test_garbage_collection.py
Outdated
Show resolved
Hide resolved
|
@mergify queue |
🛑 The pull request has been merged manuallyThe pull request has been merged manually at 6041cec |
bisgaard-itis
left a comment
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. Looks cool. Just one suggestion from my side.
services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_utils.py
Show resolved
Hide resolved
|



What do these changes do?
This PR unifies how the peridoic background tasks are setup in the garbage-collector domain of the web-server
Highlights
cleanup_ctxevent intasks_utils.pyservicelib.baground_tasks.exclusive_periodic)Follow ups
Possible follow-ups (to discuss with @sanderegg ) in order to resolve #7931
Related issue/s
How to test
These are the (few) tests we have for the GC
Dev-ops
None