Skip to content

Conversation

@GitHK
Copy link
Contributor

@GitHK GitHK commented Oct 21, 2025

What do these changes do?

  • Fixes a bug with dynamic-sidecar where it was cleaning up the entries in Redis using the node_id instead of the service_run_id.
  • Added cleanup for fire_and_forget=True long running tasks, which never had a removal procedure

Related issue/s

How to test

Dev-ops ⚠️

When releasing this to any deployment, do the following:

  • Go to Portainer and connect as root user (you have to type root since it's empty) to the redis-commander container
  • run the below commadn in the Database number 6
EVAL "for _,k in ipairs(redis.call('KEYS','*')) do redis.call('DEL',k) end" 0

Run the following cleanup

@GitHK GitHK self-assigned this Oct 21, 2025
@GitHK GitHK requested a review from Copilot October 21, 2025 11:18
@GitHK GitHK added bug buggy, it does not work as expected t:maintenance Some planned maintenance work labels Oct 21, 2025
@GitHK GitHK added this to the Imparable milestone Oct 21, 2025
Copy link
Contributor

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 bug in the long-running task (LRT) redis cleanup mechanism. The changes ensure proper cleanup of fire-and-forget tasks and correct identification of sidecar resources using service run IDs instead of node IDs.

Key Changes:

  • Updated sidecar cleanup to use service_run_id instead of node_id for proper namespace identification
  • Added tracking mechanism for fire-and-forget tasks to be removed after a timeout period once completed
  • Introduced detected_as_done_at field to track when fire-and-forget tasks finish

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_utils.py Updated cleanup function to use service_run_id instead of node_id for correct namespace identification
packages/service-library/src/servicelib/long_running_tasks/task.py Implemented fire-and-forget task cleanup logic with timeout-based removal
packages/service-library/src/servicelib/long_running_tasks/models.py Added detected_as_done_at field to track completion time of fire-and-forget tasks

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.37%. Comparing base (ffe52c1) to head (234208f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8539      +/-   ##
==========================================
+ Coverage   87.04%   87.37%   +0.33%     
==========================================
  Files        2011     1578     -433     
  Lines       78751    65758   -12993     
  Branches     1365      684     -681     
==========================================
- Hits        68545    57453   -11092     
+ Misses       9803     8065    -1738     
+ Partials      403      240     -163     
Flag Coverage Δ
integrationtests 63.96% <100.00%> (+3.59%) ⬆️
unittests 85.82% <92.85%> (-0.47%) ⬇️
Components Coverage Δ
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library 70.98% <90.00%> (+0.02%) ⬆️
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 84.95% <ø> (ø)
agent 93.10% <ø> (ø)
api_server 91.62% <ø> (ø)
autoscaling 95.83% <ø> (ø)
catalog 92.06% <ø> (ø)
clusters_keeper 99.14% <ø> (ø)
dask_sidecar 91.82% <ø> (ø)
datcore_adapter 97.95% <ø> (ø)
director 75.72% <ø> (ø)
director_v2 90.91% <100.00%> (+5.56%) ⬆️
dynamic_scheduler 96.66% <ø> (ø)
dynamic_sidecar 90.44% <ø> (ø)
efs_guardian 89.83% <ø> (ø)
invitations 90.90% <ø> (ø)
payments 92.80% <ø> (ø)
resource_usage_tracker 91.68% <ø> (-0.54%) ⬇️
storage 86.84% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 87.10% <ø> (+0.06%) ⬆️

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 ffe52c1...234208f. 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.

@GitHK GitHK requested a review from Copilot October 21, 2025 11:20
Copy link
Contributor

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@GitHK GitHK marked this pull request as ready for review October 21, 2025 11:42
@GitHK GitHK changed the title 🐛 LRT redis cleanup 🐛 LRT redis cleanup ⚠️🚨 Oct 21, 2025
@GitHK GitHK requested a review from YuryHrytsuk October 21, 2025 11:45
@mergify
Copy link
Contributor

mergify bot commented Oct 21, 2025

🧪 CI Insights

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

✅ Passed Jobs With Interesting Signals

Pipeline Job Signal Health on master Retries 🔍 CI Insights 📄 Logs
CI integration-tests Base branch is healthy, but retries were needed. Could be early signs of flakiness 👀 Healthy 1 View View
system-tests Base branch is broken, but retries were needed. Could be early signs of flakiness 👀 Broken 1 View View

@GitHK GitHK requested a review from pcrespov October 21, 2025 12:32
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. A test coverning this case (i.e. tasks not being deleted ) would also be a plus!

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

thanks

Copy link
Contributor

@YuryHrytsuk YuryHrytsuk left a comment

Choose a reason for hiding this comment

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

Thanks.

Will you execute the clean up scripts? Shall I ping you during next staging and production release?

@GitHK GitHK enabled auto-merge (squash) October 22, 2025 11:05
@GitHK GitHK disabled auto-merge October 24, 2025 09:54
@GitHK GitHK enabled auto-merge (squash) October 24, 2025 10:23
@sonarqubecloud
Copy link

@GitHK GitHK merged commit 991eab8 into ITISFoundation:master Oct 24, 2025
144 of 148 checks passed
@GitHK GitHK deleted the pr-osparc-long-running-redis-cleanup branch October 24, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug buggy, it does not work as expected t:maintenance Some planned maintenance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants