Repository navigation
Verify the public Leaf pages with a new session per attempt - #419
Conversation
The deploy's verify step asked the same session cookie twenty times. That cookie picks one Durable Object, and a container Cloudflare has already started keeps its image for its ten-minute idle timer, so every retry re-read the image that one session began on rather than the image the fleet now hands an arriving reader — which is the property the step exists to prove. Each attempt now mints its own session, and one fifteen-minute deadline covers the whole rollout instead of a fixed twenty attempts. The failure line names both layers, so the next mismatch reads off the log instead of the state body's producer commit.
leaf-agent
left a comment
There was a problem hiding this comment.
The shared deadline can leave the second page a single attempt. verify_page checks (( SECONDS < deadline )) after an attempt, so once the first call has spent the budget the second enters the loop, probes once, breaks, and fails the step — where the old fixed count gave each page twenty attempts of its own.
The description rests this on "the second page passes immediately once the first does", but the routing does not guarantee that: getContainer(env.PAGES, sessionId) in worker/src/index.ts keys the Durable Object on the session id alone, so the second page's freshly minted cookie seats a different container from the one the first page converged on. The PR's own measurement is the case in point — while the fleet was mixed, fresh sessions kept landing on the old image out to t+198s. A rollout slow enough to push the first page near 900s therefore fails on the second page's one probe and marks a healthy deploy red, which is the failure mode this change exists to remove.
A per-page floor closes it while keeping one shared wall-clock bound: declare local attempt=0 again and break only on (( SECONDS >= deadline && ++attempt >= 5 )), so the deadline still caps the job but neither page can be cut to a single probe.
|
The dumped state body names the stale side directly: The run also shows the second half of your fix earning its keep: the step ran 21:53:39 → 21:55:37, about 118 seconds, short of even the 45s-to-198s intermittent window your fresh-session polling measured. So the twenty attempts would have been too small a budget here even with a per-attempt cookie; the fifteen-minute deadline is what covers it. No new diagnosis to add — leaving this to you as the fix. |
|
Right on both counts — The floor is written as The description's "the second page passes immediately once the first does" was the claim that did not hold, since Worst case the floor extends the step past the fifteen-minute deadline by five attempts per page — at |
|
A fourth consecutive occurrence: run 34165866226, the build of Two details from this one that bear on the deadline rather than just the recurrence count. The container was serving The step spent 22:14:36–22:16:38, about 122 seconds — consistent with the twenty attempts running out well inside the window a fresh session needs, and inside the fifteen-minute deadline this PR gives it. |
Problem
publish-sitehas gone red onmaintwice since #414 introduced the layer-matching verification — run 34163256368 (the build of #414 itself) and run 34163695118 (the build of #411). Both times the deploy succeeded andVerify public Leaf pagesspent its whole budget without the edge shell's layer and/api/state's layer ever agreeing. In the second run the state body carried"producer": {"commit": "cb02617a7704"}— the container was still serving the previous deploy's image while the edge served the new shell.The step asks the same session cookie on all twenty attempts. That cookie picks one Durable Object, and
sleepAfter = "10m"onLeafWebsiteSessionkeeps a container Cloudflare has already started alive for ten minutes. So the first attempt seats a container on whatever image the rollout has reached at that instant, and the remaining nineteen attempts re-read that one instance. What the step then measures is the image one session began on — not the image the fleet hands a reader arriving now, which is the property it exists to prove.I measured both against the live site while run 34163695118's rollout was still in flight, polling a fresh session and one fixed session side by side against the edge shell's layer
6260affc:A new session reached the new image in 45 seconds. The fixed session never did, across 8.7 minutes of polling — consistent with the idle timer, and the reason the twenty attempts could not have converged however many of them ran.
Solution
Mint a session cookie per attempt, so each one asks as an arriving reader, and bound the loop by one fifteen-minute deadline shared across both pages rather than a fixed twenty attempts. The deadline is what covers the rest of what the measurement shows: a gradual rollout leaves the fleet mixed for a while, so fresh sessions still landed on the old image intermittently out to
t+198s, well past the ~145s the old loop actually spent. Fifteen minutes is entered about 2 minutes into the job and leaves margin undertimeout-minutes: 30. Sharing it between the two pages is right because they are waiting on the same rollout, but each page keeps five attempts past the deadline: the two pages mint separate cookies and so seat separate containers, and a rollout slow enough to run the first page to the deadline must not leave the second a single probe before it reports a healthy deploy red.The failure line now names both layers, and each attempt clears the state layer and body it is about to overwrite so the line reports what this attempt observed rather than an earlier one's reading. Diagnosing these runs meant inferring the mismatch from
producer.commitburied in the dumped state body, because the step printed the body and not the two values it had just compared.What this does not address
During a rollout a real reader can be served a new edge shell against an old container, and
sameLayerinlayer-client.jsreloads the tab on that mismatch — with the session cookie sticky, into a reload loop until the container's idle timer retires it. This PR makes CI observe that window honestly rather than closing it; narrowing it (a faster container rollout, or a reader-facing answer to the mismatch) is a deployment and reader-experience decision I have left to you.Testing
publish-siteruns only on pushes tomain, so this branch's CI cannot exercise the changed step. I ran the step's script as CI runs it, extracted from the workflow with the samebash -e:Extracted-step runs against the live site
Against the settled site, both pages pass on their first attempt:
The deadline path, with the deadline cut to 12s and the product predicate falsified so it can never pass — it breaks out, names both layers, dumps the body, and returns 1:
That run also caught the live failure in the act: the edge was serving #411's shell while the container still served #414's image, the same disagreement both red runs reported.
Re-running the extracted step against the settled site after the review fixes still passes both pages on their first attempt (7.2s). With the deadline set to 0 so it is already spent, the first page passes and the second still probes five times instead of once. Stubbing
curlso the shell fetch succeeds once and then fails: before the per-attempt reset the failure line reportedserved layer BBBand dumped attempt 1's body for a probe that never ran; after it, both readnone.The convergence measurement above polled
https://leaf.page/api/stateevery 15s, readingLeaf-Layerfrom the response headers, with a newopenssl rand -hex 16cookie for thefreshcolumn and one cookie held for the whole run for thefixedcolumn.pre-commit run --files .github/workflows/publish-site.yaml worker/README.mdpasses, actionlint — which shellchecks therun:block — included.Automated fix for failed run 34163256368.