Skip to content

fix: serve link's health port before waiting for the schema - #33

Merged
TheMeinerLP merged 1 commit into
mainfrom
fix/link-health-before-schema
Aug 20, 2026
Merged

fix: serve link's health port before waiting for the schema#33
TheMeinerLP merged 1 commit into
mainfrom
fix/link-health-before-schema

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Contributor

Seen in production on the first deployment: sturnus-link restarted once before coming up.

link waits up to 60 seconds for the tables the worker creates (_wait_for_schema), and starts its HTTP server only afterwards. The liveness probe fires after roughly 65 seconds. On a fresh cluster — where the tables genuinely do not exist yet — the probe kills the pod for doing exactly what it is supposed to do.

It recovered because the retry happened to land after the worker had migrated. With a slower database or a longer migration that becomes a loop the pod never escapes.

The comment on healthz already stated the intent:

Liveness only: the process answers HTTP. No dependency is checked here — a slow database must not make Kubernetes kill an otherwise-fine process.

The start order contradicted it. Now the server starts first: /healthz answers from the first moment, and /readyz returns 503 until the schema appears, so Kubernetes holds traffic back instead of restarting anything.

Two tests cover both directions — /healthz answering while the schema is absent, and /readyz flipping from 503 to 200 when it arrives. 363 tests pass.

link waits up to 60s for the tables the worker creates, and only then
starts its HTTP server. The liveness probe fires after ~65s, so on a fresh
cluster it kills the pod for doing exactly what it should. That happened on
the first real deployment: the link pod restarted once before the tables
existed, and only came up because the retry landed after the worker had
migrated.

The server now starts first, so /healthz answers immediately, and /readyz
returns 503 until the schema is there -- Kubernetes holds traffic back
without restarting anything. `healthz`'s own comment already said a slow
database must not get the process killed; the start order contradicted it.
@TheMeinerLP
TheMeinerLP merged commit dfd509c into main Aug 20, 2026
5 checks passed
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.

1 participant