Skip to content

Conversation

giancarloromeo
Copy link
Contributor

@giancarloromeo giancarloromeo commented Aug 20, 2025

What do these changes do?

This PR fixes a critical issue with Celery's Redis client lifecycle management where Redis connections were not properly cleaned up, leading to resource leaks. The fix ensures proper initialization and shutdown of Redis clients throughout the application.

  • Centralizes Redis client lifecycle management for Celery operations
  • Refactors worker initialization to remove redundant celery_settings parameter

Related issue/s

How to test

cd packages/celery-library
make tests

Dev-ops

@giancarloromeo giancarloromeo self-assigned this Aug 20, 2025
@giancarloromeo giancarloromeo added a:celery-library a:storage issue related to storage service labels Aug 20, 2025
@giancarloromeo giancarloromeo added this to the Voyager milestone Aug 20, 2025
Copy link

codecov bot commented Aug 20, 2025

Codecov Report

❌ Patch coverage is 82.35294% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.66%. Comparing base (19b60cc) to head (faa5549).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8237      +/-   ##
==========================================
- Coverage   87.81%   87.66%   -0.15%     
==========================================
  Files        1945     1529     -416     
  Lines       75564    63341   -12223     
  Branches     1314      686     -628     
==========================================
- Hits        66354    55526   -10828     
+ Misses       8813     7573    -1240     
+ Partials      397      242     -155     
Flag Coverage Δ
integrationtests 63.97% <ø> (-0.02%) ⬇️
unittests 86.07% <82.35%> (-0.41%) ⬇️
Components Coverage Δ
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library 85.21% <100.00%> (-2.14%) ⬇️
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library 71.13% <0.00%> (+0.01%) ⬆️
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 85.03% <ø> (+0.05%) ⬆️
agent 93.53% <ø> (ø)
api_server 91.94% <95.65%> (+0.03%) ⬆️
autoscaling 95.77% <ø> (ø)
catalog 92.36% <ø> (ø)
clusters_keeper 99.13% <ø> (ø)
dask_sidecar 92.37% <ø> (+0.56%) ⬆️
datcore_adapter 97.94% <ø> (ø)
director 75.81% <ø> (ø)
director_v2 90.88% <ø> (-0.09%) ⬇️
dynamic_scheduler 96.27% <ø> (ø)
dynamic_sidecar 90.46% <ø> (ø)
efs_guardian 89.62% <ø> (ø)
invitations 91.44% <ø> (ø)
payments 92.61% <ø> (ø)
resource_usage_tracker 92.13% <ø> (+0.05%) ⬆️
storage 86.65% <92.59%> (+0.16%) ⬆️
webclient ∅ <ø> (∅)
webserver 87.96% <ø> (+0.02%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19b60cc...faa5549. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

mergify bot commented Aug 20, 2025

🧪 CI Insights

Here's what we observed from your CI run for faa5549.

✅ Passed Jobs With Interesting Signals

Pipeline Job Signal Health on master Retries 🔍 CI Insights 📄 Logs
CI system-tests Base branch is broken, but the job passed. Looks like this might be a real fix 💪 Broken 0 View View
unit-tests Base branch is broken, but retries were needed. Could be early signs of flakiness 👀 Broken 2 View View

@giancarloromeo giancarloromeo requested a review from Copilot August 20, 2025 19:54
Copy link
Contributor

@Copilot Copilot AI left a 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 fixes a critical issue with Celery's Redis client lifecycle management where Redis connections were not properly cleaned up, leading to resource leaks. The fix ensures proper initialization and shutdown of Redis clients throughout the application.

  • Centralizes Redis client lifecycle management for Celery operations
  • Refactors worker initialization to remove redundant celery_settings parameter
  • Updates method names for consistency (lifespan → start_and_hold)

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/storage/src/simcore_service_storage/modules/celery/__init__.py Complete refactor to manage Redis client lifecycle with proper setup/shutdown
services/storage/src/simcore_service_storage/core/application.py Updated to use new setup_celery function name and reorganized conditional logic
packages/service-library/src/servicelib/fastapi/celery/app_server.py Added task_manager property and renamed lifespan method to start_and_hold
packages/service-library/src/servicelib/celery/app_server.py Made task_manager abstract property and renamed lifespan method
packages/celery-library/src/celery_library/signals.py Simplified worker initialization by removing redundant celery_settings parameter
packages/celery-library/src/celery_library/common.py Removed create_task_manager function that was causing lifecycle issues
services/storage/tests/conftest.py Updated test fixture to match simplified worker initialization
packages/celery-library/tests/conftest.py Updated test fixtures with proper Redis client lifecycle management
packages/service-library/src/servicelib/celery/models.py Fixed parameter name from task_context to task_filter

Copy link
Contributor

@bisgaard-itis bisgaard-itis left a comment

Choose a reason for hiding this comment

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

Very nice. Thanks

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

thx!

@giancarloromeo giancarloromeo enabled auto-merge (squash) September 12, 2025 09:00
@giancarloromeo
Copy link
Contributor Author

@Mergifyio queue

Copy link
Contributor

mergify bot commented Sep 12, 2025

queue

🛑 Configuration not compatible with a branch protection setting

The branch protection setting Require branches to be up to date before merging is not compatible with max_parallel_checks>1, queue_conditions != merge_conditions and must be unset.

@giancarloromeo giancarloromeo added the 🤖-automerge marks PR as ready to be merged for Mergify label Sep 12, 2025
Copy link

@giancarloromeo giancarloromeo merged commit ae14233 into ITISFoundation:master Sep 12, 2025
196 of 201 checks passed
@giancarloromeo giancarloromeo deleted the is8159/fix-redis-client-lifecycle branch September 12, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖-automerge marks PR as ready to be merged for Mergify a:celery-library a:storage issue related to storage service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Celery worker not calling shutdown on Redis instance
6 participants