Skip to content

fix(kind): the probe waited on a static literal, and failed with a traceback - #614

Merged
athvin merged 1 commit into
mainfrom
bm/kind-probe-readyz-and-diagnostics
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/kind-probe-readyz-and-diagnostics

Conversation

@athvin

@athvin athvin commented Nov 5, 2026

Copy link
Copy Markdown
Owner

The nightly kind probe went red on 2026-11-05 (run 41982655419) in phase 1, and the only evidence in the log was this:

File "<string>", line 1, in <module>
  import json,sys; print(json.load(sys.stdin)["id"])
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

That is enqueue()'s parse dying on empty stdin. It names neither the request nor the status — the two facts that distinguish "the API refused this" from "the port-forward died" — so the failure was not diagnosable from its own log. Two separate problems, one of which is the likely cause.

The startup gate waited on /healthz, which cannot say no

/healthz is a static literal — Json(json!({ "status": "ok" })), with a doc comment explaining that a liveness probe must not fail on a dependency outage. So it answers 200 while Postgres is unreachable and the process cannot serve a single DB-backed request.

/readyz is the real signal: it takes State, checks the DSN, and is what the chart's readiness and startup probes have read since PR1. The probe was the one caller still trusting the literal.

That fits the observed timeline exactly:

time event
07:28:25.556 org kindacme registered — the org POST landed
07:28:25.556 phase 1: the green path
07:28:35.914 traceback — the job POST got nothing for ~10s (5 tries × 2s)

The probe had already decided the API was up, on the strength of a constant. Now 90 ticks rather than 30, because readyz legitimately stays red through ensure_schema on a cold boot — which is the whole reason to wait for it rather than the literal.

api() now reports before it fails

Its comment used to say "a real 4xx/5xx still fails fast because the body is empty on every attempt and the caller's parse dies" — true, and a bad trade. curl -fsS prints no body on a 4xx/5xx, so the status and the detail were discarded and the caller's traceback was all that survived.

It now re-asks once without -f, purely to report:

check_kind: POST /v1/orgs/x/jobs gave up after 5 tries — HTTP 404: {"detail":"no such org"}
check_kind: POST /v1/orgs/x/jobs gave up after 5 tries — HTTP 000 (no HTTP response — port-forward or pod gone):

The bug that only running it would find

Both messages above are copied from real runs against a local 404 server and a closed port, not composed by hand — and that is how the one bug in this change surfaced.

The first version wrote || echo "000". But curl -w '%{http_code}' already prints 000 on a connection failure while exiting non-zero, so the fallback appended a second one. On exactly the failure it was meant to label, the message read HTTP 000000 — and because [ "$code" = "000" ] no longer matched, the parenthetical explaining what 000 means never fired. Reasoning about it would not have caught that.

Scope

No behaviour change on the happy path: same five attempts, same early return. The extra request only ever runs when the probe is already failing. Verified with bash -n and by exercising all three paths (404-with-body, dead port with a body arg, dead port without one).

This is deliberately separate from #610 so that PR's in-flight verification run stays valid — check_kind.sh is byte-identical there to the commit its probe run was dispatched against.

🤖 Generated with Claude Code

…aceback

The nightly kind probe went red on 2026-11-05 (run 41982655419) in phase 1,
and the only evidence in the log was this:

    File "<string>", line 1, in <module>
      import json,sys; print(json.load(sys.stdin)["id"])
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

That is `enqueue()`'s parse dying on empty stdin. It names neither the request
nor the status — the two facts that distinguish "the API refused this" from
"the port-forward died" — so the failure was not diagnosable from its own log.
Two separate problems, one of which is the likely cause.

**The startup gate waited on `/healthz`, which cannot say no.** It is a static
literal — `Json(json!({ "status": "ok" }))` — so it answers 200 while Postgres
is unreachable and the process cannot serve a single DB-backed request.
`/readyz` is the real signal, takes `State` and actually checks the DSN, and is
what the chart's readiness and startup probes have read since PR1. The probe
was the one caller still trusting the literal.

That fits the observed timeline exactly: the org POST landed at 07:28:25, the
very next job POST got nothing for ten seconds, and the probe had already
decided the API was up. Now 90 ticks rather than 30, because `readyz`
legitimately stays red through `ensure_schema` on a cold boot — which is the
whole reason to wait for it rather than for the literal.

**`api()` now reports before it fails.** Its comment used to say "a real
4xx/5xx still fails fast because the body is empty on every attempt and the
caller's parse dies", which was true and a bad trade: `curl -fsS` prints no
body on a 4xx/5xx, so the status and the `detail` — the whole diagnosis — were
discarded and the caller's traceback was all that survived. It now re-asks once
without `-f`, purely to report, and names the method, path, status and body:

    check_kind: POST /v1/orgs/x/jobs gave up after 5 tries — HTTP 404: {"detail":"no such org"}
    check_kind: POST /v1/orgs/x/jobs gave up after 5 tries — HTTP 000 (no HTTP response — port-forward or pod gone):

Both messages above are copied from real runs against a local 404 server and a
closed port, not composed by hand — and that is how the one bug in this change
was found. The first version wrote `|| echo "000"`, which appended a second
`000` on exactly the failure it was meant to label: the message read
`HTTP 000000`, and because the equality test no longer matched, the
parenthetical explaining what 000 means never fired. Reasoning about it would
not have caught that; running it against a closed port did.

No behaviour change on the happy path: same five attempts, same early return,
the extra request only ever runs when the probe is already failing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit ea9d1ae into main Nov 5, 2026
39 checks passed
athvin pushed a commit that referenced this pull request Nov 8, 2026
…tory

The header's premise — never observed failing, so not trusted — went stale:
the probe failed four times for four distinct causes (#614, #622, #624,
#610) and has now passed twice on main (2026-11-07 nightly 42348330935,
2026-11-08 dispatch 42447724542, all six phases both times). The decision
stands, restated on cost grounds: the in-job release-image build is the
wrong price for a PR gate and the per-PR assertions job covers the cheap
half. The timeout comment gains the measured end-to-end timings (28m42s,
33m51s of the 120 budget) that settle #655's step 2 without a raise.
athvin added a commit that referenced this pull request Nov 8, 2026
…tory (#655)

* wip: claim #655 — first green kind probe run

* docs(kind): restate the probe's not-required decision on observed history

The header's premise — never observed failing, so not trusted — went stale:
the probe failed four times for four distinct causes (#614, #622, #624,
#610) and has now passed twice on main (2026-11-07 nightly 42348330935,
2026-11-08 dispatch 42447724542, all six phases both times). The decision
stands, restated on cost grounds: the in-job release-image build is the
wrong price for a PR gate and the per-PR assertions job covers the cheap
half. The timeout comment gains the measured end-to-end timings (28m42s,
33m51s of the 120 budget) that settle #655's step 2 without a raise.

---------

Co-authored-by: bmoore813 <[email protected]>
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.

2 participants