Repository navigation
feat(health-check-api): [#2324] migrate token lifecycle - #2336
Merged
josecelano merged 10 commits intoSep 25, 2026
Merged
josecelano merged 10 commits into
josecelano merged 10 commits into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
This PR migrates the health-check API lifecycle to a token-aware shutdown model while keeping the legacy Halted-based path intact.
Changes:
- Add a token-aware server startup path (
server::start_with_cancellation) that binds, serves, registers, and drains via an injectedCancellationToken. - Update the health-check bootstrap job to supervise a token-owned server + drain controller (
TokenAwareServerTask) and join both before reporting outcomes. - Add focused tests and documentation evidence for cancellation/drain behavior, listener release, and bootstrap propagation.
| File | Description |
|---|---|
| src/bootstrap/jobs/health_check_api.rs | Switches health check job to token-aware startup and supervision; adds component-level tests. |
| src/app.rs | Passes a JobManager child cancellation token into the health-check job; adds bootstrap test coverage. |
| packages/axum-health-check-api-server/src/server.rs | Introduces start_with_cancellation, shared router extraction, and unit tests for registration/drain/rollback. |
| packages/axum-health-check-api-server/Cargo.toml | Adds dependencies needed for token-aware lifecycle and error typing (tokio-util, thiserror). |
| docs/issues/open/2324-1488-si-13-migrate-health-check-api-token-lifecycle/verification.md | Records deterministic test evidence and manual verification links for the migration. |
| docs/issues/open/2324-1488-si-13-migrate-health-check-api-token-lifecycle/manual-verification-evidence.md | Adds direct SIGTERM/rebind manual evidence for token-driven drain and clean exit. |
| docs/issues/open/2324-1488-si-13-migrate-health-check-api-token-lifecycle/implementation-retrospective.md | Captures key lifecycle/ownership lessons learned and follow-ups. |
| docs/issues/open/2324-1488-si-13-migrate-health-check-api-token-lifecycle/agent-review-reports.md | Adds an independent review report entry for the work. |
| docs/issues/open/2324-1488-si-13-migrate-health-check-api-token-lifecycle/ISSUE.md | Updates spec status, decisions, verification, and completion review notes. |
| docs/features/shutdown-process/task-inventory.md | Updates shutdown inventory rows to reflect token-aware health-check ownership and drain joining. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…art path Add start_with_cancellation, which binds, serves, registers the service, and drains through graceful_shutdown_on_cancellation with a 5-second budget. Registration failure cancels and joins both children and releases the listener. The legacy Halted-based start path is unchanged and shares the router.
…ecycle The health_check_api component now receives a JobManager child token, starts the token-aware server, and joins its server and drain-controller children before reporting one named outcome. Independent completion, panic, and runtime error paths cancel and join the drain controller first.
…ning the component Create the TokenAwareServerTask owner before returning the component future, so dropping an unpolled component aborts the server and drain controller and releases the listener. On the cancellation path, join the drain controller before mapping a server join error. Found by the independent completion review; the new regression test fails when the owner is created inside the future.
… review Add manual SIGTERM and listener-rebind evidence, fill in the verification record, save the independent task review, and record the retrospective for the ownership fix.
…stop Use the listener's actual local address instead of the configured bind address, which differs for ephemeral ports.
…e retry Sleep briefly between bind attempts instead of spinning with yield_now while waiting for the listener to be released.
josecelano
force-pushed
the
2324-1488-si-13-migrate-health-check-api-token-lifecycle
branch
from
September 24, 2026 20:03
ca67acf to
50be849
Compare
Member
Author
|
ACK 50be849 |
josecelano
added a commit
that referenced
this pull request
Sep 26, 2026
josecelano
added a commit
that referenced
this pull request
Sep 26, 2026
2e36b46 docs(pr-reviews): point PR #2336 audit to the archived #2324 spec (Jose Celano) 4f74f65 docs(issues): add issue specification for #2342 (Jose Celano) Pull request description: ## Summary Spec-only PR for SI-14 of EPIC #1488: promote the UDP token-lifecycle draft to open issue #2342 before implementation starts. - Rewrite the SI-14 spec against the current code after SI-13 merged. It records three ownership gaps in the UDP path (legacy drop path panics and detaches the receive loop, launcher abort detaches it, receive errors reported as normal completion) and maintainer-approved decisions D1-D6 with pros and cons: cooperative token stop in the receive loop, a flattened token-aware path, explicit receive failures, a single-task drop-safe owner, a safe legacy launcher adapter, and a UDP throughput baseline before implementation plus a second measurement after it. - Link #2342 from the EPIC roadmap (step 10) and update references in the SI-9, SI-15, and SI-17 drafts. - Point the PR #2336 review audit's frontmatter to the archived #2324 spec. ## Files touched - `docs/issues/open/2342-1488-si-14-migrate-udp-receive-reset-token-lifecycle/` (moved from `docs/issues/drafts/`) - `docs/issues/open/1488-overhaul-tracker-shutdown/ISSUE.md` - `docs/issues/drafts/1488-si-9-improve-udp-shutdown/`, `1488-si-15-define-udp-active-request-policy/`, `1488-si-17-migrate-standalone-udp-environment/` - `docs/pr-reviews/pr-2336-review/PR-REVIEW.md` ## Validation - `linter all` (including local link checks) via the pre-commit hook - No code changes Related to #2342 ACKs for top commit: josecelano: ACK 2e36b46 Tree-SHA512: aa34f2c3e232d55542a5dc8729563fd43fb68264380e66e6894b46aaf94b17b7f9536169c9001389659c9a0cd3d872ab2566eb7c9295d88d3d3d4f524bad94df
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
server::start_with_cancellation) that binds, serves, registers the service, and drains through the token-aware Axum helper with a 5-second budget. Registration failure cancels and joins both children and releases the listener. The legacyHalted-based start path andenvironmentstart/stop are unchanged and share the same router.health_check_apibootstrap component to aJobManagerchild token. The component owns the server and drain-controller tasks throughTokenAwareServerTask, created before the component future is returned, and joins both before reporting one named outcome on cancellation, independent completion, panic, or runtime error.Readiness and response behavior are unchanged; SI-21 owns unhealthy-during-shutdown.
Files/packages touched
packages/axum-health-check-api-server(src/server.rs,Cargo.toml: addsthiserror,tokio-util)src/bootstrap/jobs/health_check_api.rs,src/app.rsdocs/features/shutdown-process/task-inventory.mddocs/issues/open/2324-1488-si-13-migrate-health-check-api-token-lifecycle/Validation
cargo test -p torrust-tracker-axum-health-check-api-server(3 unit tests, 8 legacy contract tests)cargo test -p torrust-tracker --lib -- health_check_api(component supervision, drop-before-run listener release, bootstrap propagation)linter all, pre-commit and pre-push hooks (nightly format/check/docs and full test suite), nightly Rust1.100.0-nightly0, token-aware drain logged,health_check_apireported cooperative cancellation, immediate listener rebindFollow-ups (not in this PR)
docs/issues/open/.Part of EPIC #1488.
Closes #2324