Skip to content

Mark health check unhealthy during shutdown #2697

Closed

Description

@josecelano

Parent EPIC: #1488 (SI-21, roadmap row 21).

Goal

On a normal shutdown request, mark the tracker as not ready before components begin draining, so that /health_check returns HTTP 503 for the whole drain and Kubernetes readiness probes and readiness-aware load balancers stop routing new traffic to this instance. Already accepted connections continue through each component's own graceful shutdown policy. This task changes readiness state and the health-check stop order only; it adds no timer and no separate time budget inside the process deadline P.

Measured baseline

On the real binary, with SIGTERM and SIGINT sent to the exact PID while a held request kept a drain open for about 5 seconds, the health-check server stopped accepting at once: new connections got Connection refused (SIGTERM) or Connection reset by peer (SIGINT), and no 503 was ever seen. Cause: health_check_api has no stop-before edge, so the root cancellation stops it together with the first components. The details and caveats are in the specification's manual-verification-evidence.md.

Decision (maintainer, 2026-11-03)

Option (a): the health-check server stops last, through a stop-before edge, so it can serve 503 during the whole drain. It is reserved first, bound and spawned last, and every other supervised component stops before it. A hung component keeps it serving 503 until P, and the exit stays bounded by P with exit code 1 for any failed, panicked or aborted component. The health server's own near-instant idle drain is not budgeted inside P. The shape of the application-owned, one-way readiness state is fixed at a design review before it is wired through main.

Acceptance criteria

  • Application readiness defaults to ready only after successful startup.
  • Normal shutdown sets readiness to not ready before jobs.cancel(), and a new connection to the health-check API during the drain receives HTTP 503.
  • /health_check returns HTTP 503 while not ready and runs no downstream service probe.
  • The healthy /health_check behaviour and body are unchanged before shutdown.
  • The readiness transition is one-way and safe under concurrent health requests.
  • Deterministic tests cover ready, not ready, no probe fan-out, and ordering before cancellation, without OS signals.
  • The health-check component stops after every other supervised component, and a failed, panicked or aborted component still gives exit code 1 within P.
  • Real-binary evidence for SIGTERM and SIGINT shows timestamped 503 probes on new connections before the drain-complete and exit logs.
  • linter all passes, and the readiness contract is documented.

The full specification is in the repository under docs/issues/open/, added by the specification-only pull request.

Not in this task, recorded as a later idea: deregister services from the Registar as they shut down, so the health list stops reporting services that are no longer available.

Activity

  1. added 5 commits that reference this issue on Nov 3, 2026
  2. self-assigned this
    on Nov 3, 2026
  3. added 6 commits that reference this issue on Nov 4, 2026
  4. added a commit that references this issue on Nov 4, 2026
  5. added a commit that references this issue on Nov 5, 2026
  6. added 2 commits that reference this issue on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions