Repository navigation
Wait 25 seconds per attempt when verifying the public Leaf pages, bounded at ten minutes per probe - #377
Wait 25 seconds per attempt when verifying the public Leaf pages, bounded at ten minutes per probe#377leaf-agent wants to merge 4 commits into
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
The arithmetic checks out and I could reproduce the timing claims: run 34088384337's step ran 05:53:47→06:03:31 (584s, 2.6 min into a 30-minute job), and the 20-second cadence between failures confirms --max-time is per attempt, so 31 × 25 + 30 × 10 ≈ 17.9 min is right and stays inside the job timeout.
The diagnosis recorded in the comment is the part I'd change. In that run the seatless 500 was not the slow answer — all four 500s came back inside the ten-second cap (1.4s, 5.7s, 1.4s, 5.4s after their attempt started); the other twenty-seven attempts aborted with zero bytes received, which is a hang rather than a slow reply. The ~11.5s figure comes from the probes taken minutes later, so nothing in the run itself shows an answer arriving between 10 and 25 seconds. The change is still cheap and plausibly right, but it's a bet that the hang resolves under 25s rather than a demonstrated fix for the twenty-seven aborts, and the comment as written will point the next diagnosis at the wrong shape. Suggestion inline.
One knock-on: --fail discards the response body, so at any cap the log gets curl: (22) The requested URL returned error: 500 and never the "Maximum number of running container instances exceeded" string — the reason still has to be recovered by hand-probing. --fail-with-body would surface it, but it pipes the error body into jq, so it isn't a free swap; worth leaving as is unless the next incident makes it worth the noise.
# Conflicts: # .github/workflows/publish-site.yaml
leaf-agent
left a comment
There was a problem hiding this comment.
The comment rewrite lands: 9b2681e records the hang rather than the busy reply, and the merge carried that reading onto main's two-probe step intact. The earlier thread is resolved.
The base merge changed the arithmetic I confirmed last time, though, and nothing in the PR has caught up with it. When I checked 31 × 25 + 30 × 10 ≈ 17.9 min against timeout-minutes: 30, the step held one probe; it now holds two, each carrying the full budget. Details inline.
Two stale bits of prose that follow from the same merge, worth fixing while the arithmetic is being revisited:
- The description still reads
31 × 25 + 30 × 10 = 1075s ≈ 17.9 min ... inside the job's 30-minute timeout. That is now one probe's budget, not the step's. - The title still names
the deployed example server. The step it changes isVerify public Leaf pages, and half of what it now caps is the product route.
One correction to the new comment while it is the thing the next diagnosis reads. Both routes take a container seat is not quite what happens: both curls send the same $COOKIE, and the Worker keys the container on the session alone — getContainer(env.PAGES, sessionId) in worker/src/index.ts, with no route in the key — so the two probes take one seat between them and the second reuses what the first got. That is also the fact that keeps the doubled budget from biting in practice, so it is worth stating rather than losing.
The base merge gave the step two probes, each carrying the whole widened budget: 31 attempts at 25s plus 30 delays is ~17.9 min per curl, so the step's worst case reached ~35.8 min inside a job capped at 30. That overrun would land as a runner kill rather than as the curl error the step exists to report. --retry-max-time 600 bounds each probe's loop by time rather than by attempt count, keeping the step inside the job while each attempt still waits 25 seconds for a busy seat. The step comment also claimed both routes take a container seat; the Worker keys the container on the session alone, and both probes send one cookie, so they share one.
leaf-agent
left a comment
There was a problem hiding this comment.
The bound in 992b8ad checks out, and so does the comment it sits under. --retry-max-time on the runner's curl 8.5.0 is "Retry only within this period", so the loop stops retrying once the timer passes 600s and one in-flight attempt can still run its full --max-time 25 — the 2 × 625 = 1250s ≈ 20.9 min worst case is right, and it lands inside timeout-minutes: 30 with the step entered 2.6 min in. The seat claim in the comment is accurate too: SESSION_COOKIE = "__Host-leaf-page" and SESSION_ID = /^[0-9a-f]{32}$/ in worker/src/routing.ts accept exactly what openssl rand -hex 16 produces, sessionFromCookie therefore returns non-null on the second probe, and getContainer(env.PAGES, sessionId) keys on the session with no route in it — so the two probes do share a seat. The open thread is resolved.
What I'd raise now is not in the diff. #386, from the maintainer, rewrites this same step and is a superset of this PR:
- It reaches the same budget by the other route —
--retry 20 --retry-delay 5 --max-time 25is 21 attempts,21 × 25 + 20 × 5 = 625sper probe, the same ~20.9 min for two — so it buys the identical per-attempt patience without--retry-max-time. - It uses
--fail-with-bodywith--outputto a temp file, which recovers the "Maximum number of running container instances exceeded" string that this PR's--faildiscards and that the description explicitly leaves unrecovered. - It raises
max_instancesfrom 10 to 100 inworker/wrangler.toml, which is the ceiling this PR's Remaining risk section hands to a maintainer rather than deciding.
The two edit the same lines and will conflict. Since #386 covers this PR's per-attempt fix, plus the error body and the underlying capacity limit, I'd land that one and close this — unless the --retry-max-time shape is wanted specifically, in that case it is a one-flag addition to #386 rather than a separate PR.
|
Superseded — I'd close this in favour of #386.
What this run settles is this PR's own bet. The description called the wider per-attempt cap "a bet rather than a demonstrated fix … it helps only if the hang resolves inside it". Probing the deployed build from this runner just now, it does not: a fresh session gets the 500 back inside the widened window, so the cap never becomes the thing that was cutting the answer off. A 500 at 11.3s already fitted under |
|
Closing: #386 merged at 08:56 UTC and main now carries the whole of what this PR was for — The one shape not carried over is |
Problem
publish-sitewent red onmainat run 34088384337:wrangler deploysucceeded and the verify step then spent its whole retry budget — 05:53:47 to 06:03:31 — across thirty-one attempts, twenty-seven of which aborted withcurl: (28) Operation timed out after 10002 milliseconds with 0 bytes receivedand four of which returnedcurl: (22) The requested URL returned error: 500. The deploy itself was fine.The seat is where it goes wrong. The Worker answers a session it cannot seat with
Failed to start container: Maximum number of running container instances exceeded, and while every slot is held a seat request can also hang with no bytes at all — which is what the twenty-seven aborts are. The four attempts that did answer came back 1.4s, 5.7s, 1.4s and 5.4s into their attempt, well inside the ten-second cap, so in this run the cap did not cut off the busy reply; it cut off the hangs. The window cleared on its own: a fresh session was seated in 2.7 seconds at 06:11, roughly eight minutes after the step gave up.Solution
Raise the per-attempt cap from 10 to 25 seconds on both probes in
Verify public Leaf pages, and bound each probe's retry loop with--retry-max-time 600. The wider cap is a bet rather than a demonstrated fix: nothing in the failed run shows an answer arriving between 10 and 25 seconds, so it helps only if the hang resolves inside it. It does cover the busy reply measured by hand at ~11.5s while the window was still held, which ten seconds cut off.--retry-max-timeis what keeps the wider cap affordable.--retrycounts attempts, not time, so 31 attempts at 25s plus their delays is ~17.9 min per probe, and the step runs two of them — ~35.8 min inside a job capped attimeout-minutes: 30. That overrun would end the step as a runner kill rather than as the curl error the step exists to report. Ten minutes per probe holds the step's worst case to ~20.9 min, entered 2.6 min into the job, which is roughly the wall-clock patience the step had at the ten-second cap while each attempt now waits two and a half times as long.In practice the two probes share one container seat rather than taking one each: they send the same
$COOKIEand the Worker keys the container on the session alone (getContainer(env.PAGES, sessionId)inworker/src/index.ts, with no route in the key), so the second reuses what the first got. The step comment records that, since an earlier draft of it claimed the opposite.--retry-all-errorsstill fails the deploy if a route never answers, so a genuinely broken rollout is still caught.--faildiscards the response body, so at any cap the log recordscurl: (22) The requested URL returned error: 500and never Cloudflare's reason string;--fail-with-bodywould surface it but would pipe the error body intojq, so it is not a free swap and I have left it alone.Remaining risk, for a maintainer to weigh
The widened budget does not remove the ceiling underneath it.
worker/wrangler.tomlsetsmax_instances = 10against one container per browser session withsleepAfter = "10m", so an eleventh concurrent reader on https://leaf.page/ gets a raw 500 carrying Cloudflare's error string, and a deploy that lands during such a window is what reddened this run. Raisingmax_instances, shorteningsleepAfter, or answering a seatless session with a styled "the demo is busy" page are all decisions about cost and reader experience, so I have not made one here. Cloudflare also had an unresolved Workflows incident open from 05:12 UTC, overlapping this window; I could not tell from outside whether it held the instances or ten real readers did.Testing
Evidence
Attempt classes in the failed run, counted out of its log:
The four 500s landed 1.4s, 5.7s, 1.4s and 5.4s after their attempt started (each attempt starts one
--retry-delay 10after the previous line's timestamp), so none of them was cut off by--max-time 10.Live probes against the deployed build, before and after the window cleared:
The static route was healthy throughout (
https://leaf.page/→ 200 in 0.53s), which locates the fault at the container seat rather than the Worker or the asset build.--retry-max-timebounds the loop and still reports curl's own error, checked with the same flag shape against a closed port:Four attempts in 6s rather than the 31 that
--retry 30alone would have run.Budget arithmetic against the job's
timeout-minutes: 30: each probe is capped at--retry-max-time 600plus one in-flight attempt of up to 25s, so the step's worst case is2 × 625 = 1250s ≈ 20.9 min, entered 2.6 min into the job.pre-commit run --files .github/workflows/publish-site.yamlpasses, actionlint included.publish-siteonly runs on pushes tomain, so this branch's CI cannot exercise the changed step; merging it re-runs the workflow, since the file is in its own trigger paths.Automated fix for failed run