Repository navigation
refactor: [#2845] consolidate the shutdown supervisors and migrate the last legacy job - #2870
Conversation
…orrust#2845) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The HTTP tracker, REST API and health-check API components use one supervisor with the health-check join order: join the server, always join the drain controller, then map the errors. Adds a table test of the join and error cases, including a server-join error that must still join the controller. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…st#2845) The job is reserved and spawned with its reservation token, so it stops before the health check. Removes register_legacy, LegacyJob, legacy_cancellation_token, the root token and the legacy outcome path from JobManager, with their tests. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…th (torrust#2845) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…2845) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The cancelled-server regression test does not prove the supervisor waits for controller completion, and manual verification includes missing reproducible evidence and an unexecuted scenario marked complete.
3 open issues
What changed in this PR
This PR advances #2845’s supervised-shutdown work by sharing server supervision and migrating the last legacy job into the ordered component lifecycle.
Changes:
- Consolidates HTTP tracker, REST API and health-check supervision, joining both owned tasks before mapping errors.
- Migrates UDP ban cleanup to a reserved component that stops before the health check, and removes legacy registration.
- Updates lifecycle tests, architecture documentation and verification records.
| File | Description |
|---|---|
src/bootstrap/jobs/udp_tracker_server.rs |
Returns an unspawned, cancellation-aware ban-cleanup runner. |
src/bootstrap/jobs/tracker_apis.rs |
Uses the shared REST API supervisor. |
src/bootstrap/jobs/token_aware_server.rs |
Adds shared supervision and join/error tests. |
src/bootstrap/jobs/mod.rs |
Exposes the shared supervisor module. |
src/bootstrap/jobs/manager.rs |
Removes legacy jobs and the root cancellation token. |
src/bootstrap/jobs/http_tracker.rs |
Uses shared supervision and standardizes error wording. |
src/bootstrap/jobs/health_check_api.rs |
Replaces its local supervisor with the shared implementation. |
src/app.rs |
Registers ban cleanup as an ordered component and tests its stop order. |
src/AGENTS.md |
Updates guidance for per-component cancellation and ownership. |
docs/issues/open/2845-1488-si-26-consolidate-shutdown-supervisor/manual-verification-evidence.md |
Records signal-run results and verification gaps. |
docs/issues/open/2845-1488-si-26-consolidate-shutdown-supervisor/ISSUE.md |
Records design decisions and implementation progress. |
docs/features/shutdown-process/task-inventory.md |
Updates task ownership, diagrams and component counts. |
docs/features/shutdown-process/shutdown-architecture-examples.md |
Removes legacy root-token examples. |
docs/architecture/glossary.md |
Removes legacy-job terminology. |
docs/architecture/application-jobs.md |
Documents shared supervision and reserved ban cleanup. |
docs/adrs/20261104120915_stop_the_health_check_api_last_to_report_not_ready_during_shutdown.md |
Records ban cleanup’s inclusion in stop-last ordering. |
docs/adrs/20261021184946_order_shutdown_by_event_flow_and_drain_event_listeners.md |
Records removal of the legacy cancellation path. |
Review effort: Balanced
…est (torrust#2845) The table test's join signal only proved the controller reached its send, so it passed even when the supervisor returned on a server-join error without joining the controller. A new test gates the controller and asserts the supervisor stays pending until it is released, on both the cancelled and the unexpected-stop branch. It fails when the early return of the old HTTP and REST supervisors is restored. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing (torrust#2845) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…2845) Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at bc966c0328b6a24d39393e12c47dfacfdb60ee5f. Recomputed from the bytes at this head, against the merge base abd7a10ff; git merge-tree against develop e0a54d558 writes a clean tree, and no file this PR changes has moved on develop since the base.
Process: an implementation PR for an open issue spec, checked against the open-pull-request, commit-changes and process-pr-review skills, the issue and evidence templates, create-adr for the two amended ADRs, and docs/testing.md.
The change against its claim: one supervisor serves the HTTP tracker, REST API and health check; it joins the server, always joins the drain controller, then maps errors, which fixes the REST and HTTP cancelled branches. Only the two HTTP messages change wording. The new gated test holds the controller after it sees the cancellation and asserts the supervisor stays pending on a paused clock; restoring the early return on either branch fails it, independent of the runtime flavor. udp_ban_cleanup is a reserved component ordered before health_check_api, and the legacy path is gone.
Consistency: no new links; the only new words are ignored inline or ordinary. M2 now records the script, exit status and release of all six bindings; M3 and M4 are back to TODO. The audit record's three rows pass the validator's logic offline, and each earlier thread has a reply, a row and a resolution.
Hygiene: eight commits, author = committer, Conventional subjects with a trailing (#2845) where develop uses [#N] after the scope (no rule requires either). Each commit carries one attribution footer line (no rule in the tree on it), and the description carries one attribution footer line too. The commit-id check prints nothing; git diff --check flags seven lines, all inside recorded output (F9).
Findings: F1 (Major, drives this change request; a description edit clears it without a new head), F2 to F6 (Minor), F7 to F9 (Nit), inline.
Checked, no finding: error precedence matches the old health-check order; the deadline loop keeps its semantics; the design-note and evidence facts hold (OwnedReceiveLoop is pub(crate), the reset interval minimum is 3600 s, SI-28 is #2847); the audit's four-test count matches the filter. The test commit's statement that the old table check passed with the early return restored does not hold on the current-thread test runtime by trace, which the new test makes moot.
Checks
On the loop's compute node at this head, against the merge base abd7a10ff (receipt server-gates-kranich-908): the repository's pre-commit gate and lint roster exit 0 (51 s wall), and the review-audit validator reports 3 rows, 4 log entries and no failure. The torrust-tracker package tests pass at this head: 277 passed, 0 failed, 3 ignored across 18 binaries (27.5 s wall); at the earlier head 7c554b59e they passed 276. F1 checked against the bytes at posting: line 17 of the PR description reads Closes #2845 only after the close-out PR; this PR does not close the issue., and #2845 is open. GitHub checks at this head at posting time: "". At posting, develop is 4c8c88c0b.
|
ACK bc966c0 |
…sertion wording (torrust#2845) Drop the sentence fragment left in the reserve_stop_last docs, rewrap the reserve and cancel paragraphs, and word assert_completes_before_every so it fits the stop-last edge as well as a bus edge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s stop lines (torrust#2845) Place the UDP IP-ban cleanup among the direct components in the task inventory and give it a detail entry, count three usage-gated components, drop the stale compatibility-registry finding, and replace the root-token mention in the shutdown README with JobManager::cancel(). Re-run M2 keeping every job-manager stop line, without trailing spaces, and align the evidence frontmatter with its template. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 2eecf1415730ddca126ea77763fffea4746add9f. Recomputed from the bytes at this head, against the merge base abd7a10ff; git merge-tree against develop e0a54d558 writes a clean tree, and no file this PR changes has moved on develop since the base.
Process: the same skills as round 1, with process-pr-review for the extended audit record.
The change against its claim: ac8bfaee3 and 6aa83839f fix round 1's F2 to F9 as stated:
- the
reserve_stop_lastfragment is gone and thereserveandcancelparagraphs are rewrapped; - the helper's assertion message is neutral;
- the ban cleanup sits among the direct components and has a detail entry;
- the formula gives 14, matching the stop-order test;
- the README now says
JobManager::cancel(); - the evidence frontmatter follows its template, and
git diff --checkfrom the base is clean.
The new M2 output shows each listener asked to stop only after its producers completed, and health_check_api last, for both signals. F1 stays cleared: no closing keyword appears in the title, the description or the eleven commit messages.
Consistency: each of the twelve threads has a reply, a row and a resolution. The audit validator's logic fails offline on one row (F10), so this review is a comment, without an ACK, until it passes.
Hygiene: eleven commits, author = committer, one attribution footer line each (no rule in the tree on it), and the description carries one attribution footer line too. The skill's commit-id check prints one id (F11).
Findings: F10 and F11 (Minor), F12 (Nit), inline. None blocks; approval waits on the validator.
Checked, no finding: the new inventory bullet and Findings item match the code; the inline cspell ignores cover the truncated log words; the record's C1 to C9 IDs depart from the skill's next-ordinal rule, but the record explains them and the validator accepts them.
Checks
On the loop's compute node at this head, against the merge base abd7a10ff (receipt server-gates-kranich-922): the repository's pre-commit gate and lint roster exit 0 (67 s wall), and the review-audit validator reports 12 rows, 9 log entries and one failure, C1: resolution reference not a commit subject of the audited pull request, its follow-ups, or the local range: PR description edit (no commit) (F10). The torrust-tracker package tests pass at this head: 277 passed, 0 failed, 3 ignored across 18 binaries (32.7 s wall). F12 checked against the bytes at posting: src/app.rs lines 1393 and 1394 carry two summary lines for assert_completes_before_every, the first still naming producer and consumers. GitHub checks at this head at posting time: "". At posting, develop is d07dad10e.
…lper (torrust#2845) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…2845) Cite C1's fix by its durable reply URL and C9's check by the merge base, and record findings C10 to C12. Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at f58df8881425055ac904e1aba4814ba57cb1895a. Recomputed from the bytes at this head, against the merge base abd7a10ff; git merge-tree against develop 4342dd654 writes a clean tree, and no file this PR changes has moved on develop since the base.
Process: the same skills as before, with process-pr-review for the three new audit rows.
The change against its claim: f84600ebe drops the stale summary line, so the helper has one doc line, naming first and later (F12 fixed). f58df8881 cites C1's fix by the reply URL that states the description edit (F10 fixed), cites C9's check by the merge base, and records C10 to C12. The description is unchanged, and neither it, the title nor the thirteen commit messages carry a closing keyword.
Consistency: each of the fifteen threads has a reply, a row and a resolution, and the audit validator's logic passes offline (15 rows, no failure). The skill's commit-id check still prints bc966c032, now from the C11 entry itself (F13).
Hygiene: thirteen commits, author = committer, one attribution footer line each (no rule in the tree on it), and the description carries one attribution footer line too. git diff --check from the base is clean.
Findings: F13 (Minor), inline and non-blocking. The merge commit keeps that id reachable from develop, and the line can be fixed later. F1 to F12 are fixed.
Checked, no finding: the C10 to C12 severities match their source comments, each reply sits on its own thread, and the cited subjects are the two new commits. The additions bring no new words.
Checks
On the loop's compute node at this head, against the merge base abd7a10ff (receipt server-gates-kranich-927): the repository's pre-commit gate and lint roster exit 0, and the review-audit validator reports 15 rows, 12 log entries and no failure. The torrust-tracker package tests pass at this head: 277 passed, 0 failed, 3 ignored across 18 binaries (32.8 s wall). F13 checked against the bytes at posting: line 244 of docs/pr-reviews/pr-2870-review/PR-REVIEW.md names the PR-branch commit bc966c032; the F10 fix holds, as line 232 now cites the thread reply URL for the description edit. GitHub checks at this head at posting time: "". At posting, develop is 4342dd654.
|
ACK f58df88 — C1's resolution reference and the helper's doc line are fixed, and the 15 audit rows pass the validator's logic at this head |
|
ACK f58df88 |
|
Post-merge workflow approval for the late finding F13 (review 5916759580, submitted 2026-11-16 08:08 UTC, before this PR merged at 08:27 UTC): the maintainer approved in chat at about 08:17 UTC to merge this PR as is and fix F13 in the #2845 close-out PR #2880, which also records it as C13 in this PR's audit. Posted by |
… evidence 1f070c9 docs(pr-reviews): audit the second da2ce7 review of PR 2880 (#2845) (josecelano-bot) eaee14a docs(pr-reviews): record the post-merge approval for C13 in the PR 2870 audit (#2845) (josecelano-bot) 816c4e6 docs(pr-reviews): audit the reviews of PR 2880 (#2845) (josecelano-bot) 2a801f8 docs(issues): address the review of the #2845 close-out (josecelano-bot) d134eed docs(pr-reviews): link the close-out PR from the C13 entry of the PR 2870 audit (#2845) (josecelano-bot) fc93980 docs(issues): close out #2845 with the M3 and M4 evidence (josecelano-bot) Pull request description: Closes #2845 (SI-26 of EPIC #1488). Close-out of PR #2870, which merged the implementation. ## Changes - Archives the spec to `docs/issues/closed/2845-1488-si-26-consolidate-shutdown-supervisor/` with `status: done`, `related-pr: 2870`, the acceptance criteria and checkpoints ticked, and a progress-log entry. - Records the two manual scenarios that were still TODO, run on a binary built from `develop` after the merge: - **M3, failure path** (SI-21 V6 recipe, P = 4 s, a partial REST request held open): exit status 1 at 2.04 s; `http_api` reported failed with "tracker API graceful drain timed out"; `health_check_api` asked to stop after it and did not delay the exit; every binding released. - **M4, ban reset** (`ip_bans_reset_interval_in_secs = 3600`, the minimum the configuration accepts): twelve announces with a wrong connection ID banned the IP (metric 1, connect unanswered); 3603 s after start the ban was reset (metric 0, connect answered); exit 0 on SIGTERM. - Adds `implementation-retrospective.md`: the M4 interval constraint the spec missed, the first regression test that passed with the old early return, and docs drift that symbol-name greps did not catch. - Marks EPIC #1488 row 23 Done with the closed path. - Records the approving review's F13 (a PR-branch commit id quoted in the audit) as C13 in `docs/pr-reviews/pr-2870-review/PR-REVIEW.md` and replaces the id with the commit subject, as agreed when PR #2870 was merged as is. ## Verification - Pre-commit checks pass (cspell, markdownlint, clippy, rustfmt, shellcheck). - The `open-pull-request` commit-id check prints nothing. - No live reference to `docs/issues/open/2845-...` remains. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: da2ce7: ACK 1f070c9 — F6 is fixed with a timed post-merge approval record, all nine threads have a reply and an audit row, and both audit records pass the validator's offline logic at this head josecelano: ACK 1f070c9 Tree-SHA512: cb03f4b36f2a05c2afe1d2335be4f7410a2a25ddc528cc7a3d1bff93c32fc681f15afb7f787a357a8d286f97d848dece431d9ef24b3c73e60b7f31eee0dd4aa4
7c721bc docs(pr-reviews): audit the second da2ce7 review of PR 2882 (#2845) (josecelano-bot) 8ed6aca docs(pr-reviews): record F4's severity mark and narrow its SHA rule in the PR 2882 audit (#2845) (josecelano-bot) 56e5b43 docs(pr-reviews): address the review of PR 2882 (#2845) (josecelano-bot) d944f07 docs(pr-reviews): mark C13 of the PR 2870 audit fixed after the close-out merged (#2845) (josecelano-bot) Pull request description: Finishes the post-merge step from the PR #2870 review for #2845 (SI-26 of EPIC #1488). Cameron's late finding F13 on #2870 (audit row C13) was deferred to the close-out PR #2880. The `process-pr-review` skill keeps such a row `FOLLOW_UP` / `OPEN` until the follow-up merges. #2880 merged into `develop` at 13:39 UTC, so this PR: - marks C13 `FIXED` / `RESOLVED` in `docs/pr-reviews/pr-2870-review/PR-REVIEW.md`; - cites the fix by its commit subject (`docs(issues): close out #2845 with the M3 and M4 evidence`); - links the reply that resolved the F13 thread (#2870 (comment)) and adds the Processing Log entries; - records the review of this PR in `docs/pr-reviews/pr-2882-review/PR-REVIEW.md`. PR #2870 has no unresolved review threads left. Docs only. #2845 is already closed, so there is no closing keyword. ## Validation Run as `josecelano-bot` (`GH_TOKEN` set to the bot token for `gh`): - `validate-audit-record.py --pr-number 2870`: `{"status": "ok", "rows": 16, "log_entries": 20, "failures": 0}`. - `validate-audit-record.py --pr-number 2882`: `{"status": "ok", "rows": 7, "log_entries": 9, "failures": 0}`. - The `open-pull-request` commit-id check over the changed files prints nothing. - The pre-commit hook (`linter all`: markdownlint, cspell and the rest) passes on every commit. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: da2ce7: ACK 7c721bc — F5 and F6 are fixed and F7 is recorded with no change at this head, the PR 2882 record passes the validator's logic against the captured comments (7 rows, 9 log entries), the commit-id check prints nothing and the branch merges cleanly with develop josecelano: ACK 7c721bc Tree-SHA512: cac3e7e1434e5346cba451225a17dee140c9f072c1f6ae82457d317d4dd7936fed74737b82d56116d2e35159de5624769cc6fec605ff316f1fe75a54dc0bea87


Implements #2845 (SI-26 of EPIC #1488).
Changes
src/bootstrap/jobs/token_aware_server.rs) for the HTTP tracker, REST API and health-check API. It joins the server, always joins the drain controller, then maps errors. A table test covers the join and error cases;it_should_wait_for_the_drain_controller_when_the_server_join_failscovers a server-join error that must still join the controller. Only the two HTTP tracker error messages change wording (the REST and health-check template is used for all three).udp_ban_cleanupis a reserved component, so it stops before the health check. A test insrc/app.rsasserts the order.register_legacy,LegacyJob,legacy_cancellation_tokenand the manager's root token, with their tests.OwnedReceiveLoopstays package-local (decision recorded in the spec: the package cannot depend on the root crate, and unifying needs a new shared crate).src/AGENTS.mdupdated; the spec has the T1 design note andmanual-verification-evidence.md.Verification
udp_ban_cleanupcompletes beforehealth_check_apiis asked to stop, the other components stop in the order of their edges, every binding released.Related to #2845. The issue stays open after this PR: the remaining manual scenarios and the close-out PR follow.
🤖 Generated with Claude Code