Repository navigation
fix(helm): the frontend keeps serving 10 s after it is marked for deletion - #2350
Merged
Merged
Conversation
…etion ingress-nginx drops a terminating pod from its upstreams a moment after the deletion, while nginx in the frontend image exits at once on SIGTERM. A request sent in that gap goes to a pod that is gone and waits out ingress-nginx's 5 s proxy_connect_timeout before it retries. Both rollouts on 2026-10-19 showed exactly one such 5 s hang, each during the second pod swap. The backend already has the same 10 s preStop sleep; CI now asserts the frontend's too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MCgCsf3UJRCPRbnNKxsECe
lilyshen0722
commented
Oct 19, 2026
lilyshen0722
left a comment
Contributor
Author
There was a problem hiding this comment.
Gate review @ 8a861cd4ec: PASS. It merges in its own Thu 10-22 / Fri 10-23 slot, not before.
What I checked
- The rendered chart changes only where the PR says. I rendered the dev chart at main and at this head with the CI invocation (
helm template commonly-dev … -f values.yaml -f values-dev.yaml). The only difference is the frontend container'slifecycle.preStopblock and its comment: 4449 → 4459 lines, nothing else. - The hook can run in this image. The frontend's final stage is
nginx:alpine. On the live frontend pod,/bin/shis busybox andcommand -v sleepgives/bin/sleep. A hook whose binary is missing would fail and leave the gap open, so this was the thing to measure. - It matches the backend exactly. The command is the same
["/bin/sh", "-c", "sleep 10"]as the backend container'spreStop. The pod sets noterminationGracePeriodSeconds, so the default 30 s easily covers 10 s of hook plus nginx's shutdown. - It fits the rollout shape from #2342. With 2 replicas,
maxSurge 0andmaxUnavailable 1, the pod being replaced keeps answering for 10 s while ingress-nginx drops it, and the other replica keeps serving. So the change can only shorten a request's wait. - There's a reader. The new
tests.ymlline assertscommand[2] == "sleep 10"on the rendered frontend container, the same way the backend's is checked. CI: 14 pass, 2 skipping. The author is Lily (noreply), and the head matches the branch.
Not checked, non-blocking. The comment says nginx "exits at once on SIGTERM". I didn't measure which stop signal this nginx image receives under the cluster runtime. The fix doesn't depend on it: the gap it closes is the one between the pod being marked for deletion and ingress-nginx removing it, which comes before any signal. The proof is your slot test: a 1 s probe through the deploy plus two rollout restart runs, with 0 non-200.
GATE: PASS
The preStop comment said nginx exits at once on SIGTERM. The frontend image inherits nginx:alpine's StopSignal SIGQUIT (read from both image configs), and the runtime uses it when the pod spec sets none. SIGQUIT is nginx's graceful quit, which exits as soon as no request is in flight, so the race and the fix are unchanged. Comment only; the rendered objects are identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MCgCsf3UJRCPRbnNKxsECe
lilyshen0722
commented
Oct 20, 2026
lilyshen0722
left a comment
Contributor
Author
There was a problem hiding this comment.
Re-gate at 523d65dc (previous PASS was at 8a861cd4).
- The one commit since then (
523d65dc, author Lily Shen) changes only the comment abovelifecycleinfrontend-deployment.yaml, 6 lines for 5.preStopis still["/bin/sh", "-c", "sleep 10"], and nothing outside YAML comment lines moved. - The corrected comment holds: the official nginx images set
STOPSIGNAL SIGQUIT, and SIGQUIT is nginx's graceful quit. The conclusion is unchanged either way: nginx is gone before ingress-nginx drops the pod, so the sleep is still the fix. - The PR body's Fail line now says the fallback is a longer sleep, not
nginx -s quit. That matches the comment. - CI at this head: 14 pass, 2 skipping.
Hold for the Thu 10-22 / Fri 10-23 slot, as before.
GATE: PASS
This was referenced Oct 21, 2026
Merged
lilyshen0722
marked this pull request as ready for review
October 22, 2026 10:21
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge after: the Thu 10-22 / Fri 10-23 change slot. This is a draft, held for that slot. Don't press it before then, and it is not part of Tuesday's deploy.
What happened
Today's two Deploy Dev rollouts each had one request hang during the frontend swap. I probed
https://commonly.me/v2every 2 s, with a 5 s client timeout, through both rollouts.The API probes in rollout 2 answered 200 every time; the backend already has a
preStopsleep.Why
preStop. Its stop signal is SIGQUIT (inherited from nginx:alpine, read from both image configs), nginx's graceful quit, which exits as soon as no request is in flight. So the pod is gone, and its address stops answering, before ingress-nginx drops it.proxy_connect_timeoutbefore trying the next upstream. That timeout is 5 s (read from the controller's livenginx.conf, withproxy_next_upstream error timeoutand 3 tries).Change
The frontend container gets the backend's
preStop(sleep 10), so a terminating pod keeps serving until ingress-nginx has dropped it.helm templatewithvalues.yaml+values-dev.yamlchanges only this:@@ frontend Deployment, container "frontend" initialDelaySeconds: 10 periodSeconds: 5 + lifecycle: + preStop: + exec: + command: ["/bin/sh", "-c", "sleep 10"] nodeSelector:The template's six-line comment also renders; it is left out above.
tests.ymlasserts the rendered frontendpreStopthe same way it already asserts the backend's.Cost
Each frontend pod takes about 10 s longer to stop. The hostname anti-affinity is required, so a replacement pod likely waits for the old pod to leave its node. That would stretch each swap by about 10 s, all of it on the other replica, which is what
maxUnavailable: 1already allows. Grace stays at the default 30 s; 10 s of sleep plus the nginx stop fits inside it.Test plan (in the slot, not before)
kubectl rollout restart deploy/frontendruns. That's four pod swaps, each with a server-sidepreStop.nginx -s quitin the hook would add nothing, because SIGQUIT already is one. That decision waits for the measurement.🤖 Generated with Claude Code
https://claude.ai/code/session_01MCgCsf3UJRCPRbnNKxsECe