Task: Close service sessions on shutdown
Table of Contents
This page documents a task in the Record service lifecycle events and surface them in system health story. It captures the goal, current status, acceptance, and any notes or results.
1. Goal
A graceful shutdown closes the sessions the process opened. Seven processes
log in as their service account through make_service_token_provider
(ores.iam.client): ores.synthetic, ores.ore, ores.reporting,
ores.scheduler and ores.marketdata services, the http server, and IAM's
own registrar. The provider logs in with service_login_request and refreshes
its token, but nothing ever sends iam.v1.auth.logout. So every restart
leaves an open session behind until it expires, and the session records
overstate who is signed in. The logout joins the shutdown that the shared
service lifecycle already runs: after the stopped event, before
nats.drain().
2. Status
| Field | Value |
|---|---|
| State | BACKLOG |
| Parent story | Record service lifecycle events and surface them in system health |
| Now | Not yet started. |
| Waiting on | Nothing. |
| Next | Begin implementation. |
| Last touched | 2026-10-06 |
3. Acceptance
- The service token provider can log out: it sends
iam.v1.auth.logoutwith its current token and forgets the token. - The shared service lifecycle logs the service out on a graceful shutdown,
after the
stoppedevent and beforenats.drain(), so no service wires it by hand. - A logout that fails is logged and never blocks the shutdown.
- A test proves a service session is closed after a graceful stop, and the session records show no open session for a stopped service.
4. Plan
(Implementation strategy. Written when work starts; key decisions
are distilled into the parent story's * Decisions at close, but the
plan itself stays — it is the historical record of what we did.)
5. Measurements
Every number this task claims about a tree, with the command that produced it
and the commit it was measured at. A number without both is not a measurement,
because a clean-up record describes a tree and trunk moves under a branch: a
consumer count, a gate's component count and a suite's size all change with no
code changing, and the reader of a bare number cannot tell which tree it came
from. Where the raw output matters, put it in an evidence/ file beside the
task and name that file in the Command column.
| What | Value | Command | Commit |
|---|---|---|---|
6. Notes
Raised by the operator on 2026-10-06, beside
Record service starts and stops:
both run in the same shutdown hook, so the order is the stopped event, then
the logout, then the drain. Interactive clients already log out: the shell,
the http server's login routes and the web client call iam.v1.auth.logout.
7. Test Scenarios
Manual QA scenarios (scaffolded via compass add test_scenario)
that verify this task. Link
new ones here as they're created; the scenario doc itself links back
via its "Verifies task" field.
| Scenario | State | Notes |
|---|---|---|
8. PRs
| PR | Title |
|---|---|
9. Review
| Comment summary | File | Decision | Notes |
|---|---|---|---|