Repository navigation
Retry the deploy gate's agent pass when the edge answers 503 during a container rollout - #790
Conversation
… container rollout
|
Two more deploys have failed this way since this PR opened, on the same line and the same request. With run 35320758891 that makes three consecutive
Both new runs end at The asymmetry the description names is what the logs show, twice over. On
Nothing here asks for a change to the diff; it is the occurrence evidence behind classifying the cause as durable. |
…835) Two changes from re-tracing #658, which is closed: its live failure mode was fixed by #790 before its last comment was written, and that comment's account of the cause is wrong. The correction and its evidence are on the issue. ## The deploy gate reads its activating request in one place `publish-site`'s release pass and its agent pass both `GET api/view`, the request that allocates a reader's container. While the container image is still propagating, the Worker's `rollingOut` answers it with `503` and a `Retry-After`. Since #790 the agent pass recognises that and waits; the release pass read the same answer as a bare status and raised `… returned 503`, which is the line [run 35320758891](https://github.com/max-sixty/leaf/actions/runs/35320758891) printed seven times — six inside the workflow's `until` loop, which reran the script and went green, then the seventh in the agent pass, which ended the deploy. Workers Observability settles what those seven were. One request logs twice under a single `traceId`, once for the Durable Object and once for the stateless Worker; for the fatal `api/view` at 07:48:37 (`traceId c3a65be546478da87775ae3682c42305`) the Durable Object answered **200** and the Worker answered **503**. `rollingOut` is the only Worker path that makes that conversion, and it sends the header. `activation_read` now makes the request for both passes and returns `None` while the rollout is still landing, so the release pass reports it in the sentence the agent pass already uses. Neither wait moves: the agent pass keeps its 180 seconds, and the release pass keeps relying on the workflow rerunning it. A `503` without `Retry-After` — what `@cloudflare/containers` returns when no instance can be allocated — is still this release failing on the first read, which one of the two new cases pins. ## A reader is told what a 503 means The open question on the issue was whether a reader arriving at a cold page gets this too. They do, and their gesture has always landed: `deliver` retries every two seconds. But the notice it showed came from the JSON decode that `rollingOut`'s plain-text body fails — "Couldn't read the answer — retrying your change…" — which reports the page failing to read an answer the server never sent. `deliver` now reads the status before decoding. A `503` on the page's one door is the server saying it cannot take this yet, whatever the reason, so the browser needs no equivalent of the gate's header test: the gate has to separate the two 503s because it decides pass or fail, while both mean the same retry here. The reader is told "The server isn't ready yet — retrying your change…". ## Verification Both runtime claims were established by running the shape rather than reading it: a preview with `rollingOut`'s exact answer replayed at `/api/event` refuses the attempt and the outbox retries it, landing the gesture when the refusal stops, under the old wording and the new. Each new case was verified paired — removing the branch it covers reds it, restoring greens it. `uv run pytest tests` and `uv run pytest tests/test_render_outbox.py` are green, as is pre-commit over every changed file. Ref #658 > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
publish-siteonmainat c9a5f207 failed in Verify the exact public release in Chrome — run 35320758891. The deploy itself succeeded: the release pass printed✓ https://leaf.page serves release a471af1a… in /usr/bin/google-chromeat 07:48:31. Six seconds later the agent pass gave up on its first request:The 503 is the edge's rollout answer, not a fault
GET api/viewis the request that activates a private session, so it is the one that allocates a container. Until the container image rollout reaches that allocation, the container answers for the previous release, androllingOutrefuses to hand it on: the reader is unseated and every request butGET api/stategets503withRetry-After: 5.worker/README.mdstates that contract andworker/test/index.test.tsholds the Worker to it.agent_sessionwas already built to wait this out. Its docstring says so — "a rollout may still be propagating between edge locations, so the gate retries with a fresh context until both readings agree" — and its 180-second loop retries wheneverreader_sessionreports an allocation on the wrong release. But it only ever saw that condition as a release header to compare, which is how the Worker used to surface it. #775 changed the edge to answer for itself, and on this path the same condition now arrives as a status.check(activated.ok, …)sits ahead of the comparison, so the retryable case became a hard failure before the loop could ever see it.That is also why the release pass ahead of it was green on the same rollout: the workflow's
untilloop reruns the whole script, so it absorbed four rounds of exactly this 503 (07:46:57 through 07:48:06) before the fifth landed. The agent pass has no such loop — deliberately, since it posts a comment — and its own wait was the thing that had stopped covering the case.The change
reader_sessionnow recognises the Worker'srollingOutanswer and returns it as one more reason this allocation cannot admit a turn, soagent_session's existing retry picks it up. Both reasons — a container that answered for another release, and the edge answering in its place — end in the same 180-second wait and the same message, which now names which reading ran the bound out.Nothing about the bound, the write, or the rest of the gate moves: an allocation that never comes good still fails the deploy, just with
reached no container able to admit its agent's turn; the last allocation was a container the image rollout had not reachedinstead of a bare status.rolling_outmatches onRetry-Afterrather than on the status alone — the Worker is the only thing in the system that sends it — so a container's own503— which comes back through the pass-through path withLeaf-Session: activeand noRetry-After— is still a failure rather than something the gate waits out.Verification
Two cases in
tests/test_website_server.pydriveagent_sessionagainst a fake allocation answeringapi/viewexactly asrollingOutdoes. Both were verified paired — they reproduce the run's own… returned 503without the change and pass with it:test_the_agent_pass_waits_out_an_allocation_the_rollout_has_not_reached— the unseated context is closed, a fresh one is opened, and the turn runs on the second allocation.test_a_rollout_that_never_lands_ends_the_agent_pass_naming_it— past the deadline the pass still fails, and the message names the rollout.uv run pytest tests/test_website_server.pyis green (78 passed), as is pre-commit over both files.Why this is filed as a durable cause rather than a transient one
The rollout window is real on every deploy; whether the agent pass opens its session inside it is timing. The next deploy — run 35320965464 on e5394c64 — went green, so leaf.page is published and current, and this commit needs nothing further. What is durable is the gate: since #775 landed on 2026-09-17 there is no wait covering this answer, so a deploy that allocates a moment earlier fails again. The two prior open trackers are different shapes — #658 is the Cloudflare control plane in the push and deploy steps, #772 is a hosted turn follower that never binds its delivery.