Skip to content

feat(shutdown): [#2221] migrate activity metrics updater to cancellation token - #2224

Merged
josecelano merged 4 commits into
torrust:developfrom
josecelano:2221-migrate-activity-metrics-updater
Sep 15, 2026
Merged

josecelano merged 4 commits into
torrust:developfrom
josecelano:2221-migrate-activity-metrics-updater

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

  • Replace the activity metrics updater's direct Ctrl-C listener and pre-spawned handle with an unspawned CancellationToken runner directly supervised by JobManager.
  • Add deterministic cancellation, weak-collaborator expiry, and named supervisor-outcome tests.
  • Remove the production Tokio signal feature from swarm-coordination-registry, retain Tokio test-util only for paused-time tests, and document udp_ban_cleanup as the remaining legacy periodic handle.
  • Add the issue specification, independent review, and manual verification evidence.

Files and packages

  • packages/swarm-coordination-registry
  • src/bootstrap/jobs/activity_metrics_updater.rs
  • src/app.rs
  • src/AGENTS.md
  • docs/issues/open/2221-1488-si-5-migrate-activity-metrics-updater/

Validation

  • Focused package lifecycle tests: injected cancellation and weak-collaborator expiry.
  • Focused application test: peers_inactivity_update reports JobStatus::Cancelled through JobManager.
  • Direct-binary SIGTERM verification: recorded updater cancellation log and cooperative manager outcome.
  • Direct-binary normal-operation verification: recorded two 15-second activity metrics update cycles.
  • linter all, workspace documentation tests, pre-commit checks, and pre-push checks passed.

Closes #2221

Parent EPIC: #1488

Move the SI-5 shutdown draft to docs/issues/open/ as the specification for
GitHub issue torrust#2221 (migrate the activity metrics updater to CancellationToken)
and mark it as sequence 4 in the EPIC torrust#1488 roadmap.

Related to torrust#2221
Related to torrust#1488
Replace the updater's direct Ctrl-C listener and pre-spawned handle with a token-aware runner directly supervised by JobManager. Add deterministic lifecycle and manager-outcome tests, document the remaining UDP compatibility handle, and record verification evidence.

Closes torrust#2221
Copilot AI lite review requested due to automatic review settings September 15, 2026 10:21
@josecelano josecelano self-assigned this Sep 15, 2026
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.95833% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.48%. Comparing base (492cc89) to head (8a1c0b3).

Files with missing lines Patch % Lines
...egistry/src/statistics/activity_metrics_updater.rs 98.24% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2224      +/-   ##
===========================================
+ Coverage    85.45%   85.48%   +0.03%     
===========================================
  Files          353      353              
  Lines        31240    31315      +75     
  Branches     31240    31315      +75     
===========================================
+ Hits         26695    26771      +76     
- Misses        4171     4173       +2     
+ Partials       374      371       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Migrates the activity metrics updater to direct JobManager supervision with CancellationToken cancellation.

Changes:

  • Replaces the legacy Ctrl-C listener with a cancellable runner and lifecycle tests.
  • Removes Tokio’s production signal feature.
  • Updates shutdown documentation, issue specifications, and verification evidence.
File summaries
File Description
src/bootstrap/jobs/activity_metrics_updater.rs Updated as part of this pull request.
src/app.rs Updated as part of this pull request.
src/AGENTS.md Updated as part of this pull request.
packages/swarm-coordination-registry/src/statistics/activity_metrics_updater.rs Updated as part of this pull request.
packages/swarm-coordination-registry/Cargo.toml Updated as part of this pull request.
docs/issues/open/2221-1488-si-5-migrate-activity-metrics-updater/manual-verification-evidence.md Updated as part of this pull request.
docs/issues/open/2221-1488-si-5-migrate-activity-metrics-updater/ISSUE.md Updated as part of this pull request.
docs/issues/open/2221-1488-si-5-migrate-activity-metrics-updater/agent-review-reports.md Updated as part of this pull request.
docs/issues/open/1488-overhaul-tracker-shutdown/ISSUE.md Updated as part of this pull request.
docs/issues/drafts/1488-si-5-migrate-activity-metrics-updater/verification.md Updated as part of this pull request.
docs/issues/drafts/1488-si-5-migrate-activity-metrics-updater/ISSUE.md Updated as part of this pull request.
Review details

Suppressed comments (4)

docs/issues/open/2221-1488-si-5-migrate-activity-metrics-updater/ISSUE.md:11

  • last-updated-utc is 09:30, but this same specification records changes through 10:04 UTC at lines 216–219. The metadata is stale; update it to the timestamp of the latest content change before merging.
last-updated-utc: 2026-09-15 09:30

docs/issues/open/2221-1488-si-5-migrate-activity-metrics-updater/ISSUE.md:10

  • This issue is being delivered by PR #2224, but the new specification leaves related-pr null. Existing folder-style issue specs record the implementation PR in this field; set it to 2224 so the issue-to-PR relationship remains queryable.
related-pr: null

docs/issues/open/2221-1488-si-5-migrate-activity-metrics-updater/ISSUE.md:197

  • This progress entry retains a literal reference to the draft spec that this PR deletes. The resulting path is stale and breaks navigation; point the entry at the new open spec (or describe the move without a dead path).
- [x] Folder-style spec drafted in `docs/issues/drafts/1488-si-5-migrate-activity-metrics-updater/ISSUE.md`

packages/swarm-coordination-registry/Cargo.toml:27

  • Removing signal from the explicit list does not remove it from this package's production Tokio feature set because default-features remains enabled and Tokio's default features include signal. The advertised feature trim is therefore ineffective; disable default features and explicitly retain the features this package uses, including time for tokio::time.
tokio = { version = "1", features = [ "macros", "net", "rt-multi-thread", "sync" ] }
  • Files reviewed: 11/11 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Add separate registry and statistics repository expiry tests and align issue metadata and review evidence with the documented conventions.

Related to torrust#2221
@josecelano

Copy link
Copy Markdown
Member Author

ACK 8a1c0b3

@josecelano
josecelano merged commit 45e04b8 into torrust:develop Sep 15, 2026
19 checks passed
josecelano added a commit that referenced this pull request Sep 15, 2026
…ssues/closed

ca2cd4e docs(review): document PR #2227 copilot suggestions audit (Jose Celano)
f8bc7db docs(review): address PR #2227 timestamp feedback (Jose Celano)
7a4301a chore(issues): archive closed issue #2221 spec to docs/issues/closed (Jose Celano)

Pull request description:

  ## Summary

  - Archive the completed #2221 SI-5 specification, review records, and manual verification evidence under `docs/issues/closed/`.
  - Update EPIC #1488 to mark SI-5 complete and link the archived specification.
  - Align current job-ownership and shutdown task-inventory documentation with direct `JoinSet` supervision for `peers_inactivity_update`; `udp_ban_cleanup` is now the sole legacy periodic job.

  ## Validation

  - Verified GitHub issue #2221 is `CLOSED` and implementation PR #2224 is merged.
  - Reviewed and repaired live references to the archived spec; retained only immutable historical PR-review references.
  - Independent task review passed.
  - `linter all`, pre-commit checks, pre-push checks, nightly workspace format/check/docs, and the full test suite passed.

  Related to #2221
  Related to #1488

ACKs for top commit:
  josecelano:
    ACK ca2cd4e

Tree-SHA512: 7d9e94a8373b6b0207ad0a3bdb3e5136a199ac01f4c82207c7fe250291d4cfa8027f0c95eb440405998c43a4a4c264b578143a1b4e0515623d03d1881e2a147a

This branch was previously deployed

1 inactive deployment
coverage — 8a1c0b30 Deployed Sep 15, 2026 by josecelano via Generate Coverage Report #2108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate activity metrics updater to CancellationToken

2 participants