fix(kourier): extend gateway drain to match axon request timeout (3605s) - #5
Open
jonoirwinrsa wants to merge 1 commit into
Open
fix(kourier): extend gateway drain to match axon request timeout (3605s)#5jonoirwinrsa wants to merge 1 commit into
jonoirwinrsa wants to merge 1 commit into
Conversation
Kourier fronts axon, which runs with timeoutSeconds 3605. The 15s drain window cut long-running requests off on gateway shutdown and rollout. DRAIN_TIME_SECONDS 15 -> 3605, terminationGracePeriodSeconds 30 -> 3665, preserving the documented grace > drain invariant. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
yaseenisolated
approved these changes
Aug 12, 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.
Supersedes CerebriumAI/kserving#215 — please close that one. It edited
third_party/kourier-latest/kourier.yaml, which is knative/serving's nightly kourier-latest pin used by the e2e harness (version label20250418-96095402). Production gateways carryapp.kubernetes.io/version: 1.18.0and are created by the operator from this kodata manifest, so #215 would never have reached a cluster.What
DRAIN_TIME_SECONDS: 15 → 3605terminationGracePeriodSeconds: 30 → 3665Kourier fronts axon, which runs
timeoutSeconds: 3605. The 15s drain cut long-running requests off on rollout. Deployment strategy is alreadymaxUnavailable: 0 / maxSurge: 100%, so replacements are Ready before old pods start draining and capacity is preserved.Sizing (measured, 100.2M requests / 14d)
3665s is chosen as the knee, not as full coverage. 8,865 requests sit in the dense 54–60m band against axon's timeout, so a grace period set under an hour would truncate most of them. Above 3665s there are still 3,497 requests (1,089 over 6h) —
max-revision-timeout-secondsis 43200, so user revisions can legitimately outlive any practical drain window. Contrary to #215's description, this does not guarantee zero dropped requests; it moves truncation from 0.013% to 0.0035%. Extending to 2h would recover only ~2,300 more while making every node operation take two hours.Measured on a live gateway
Validated on
cortex-dev-virginia. 200 concurrent requests, 45s each, gateway pod deleted 20s in. Identical test either side; only the drain config differs.Code -1Code 200Sockets used: 200 (for perfect keepalive, would be 200)in both, so the difference is the drain window, not connection behaviour.The preStop hook is
curl .../drain_listeners?graceful; sleep $DRAIN_TIME_SECONDS. That sleep is unconditional — it does not wait on connections, it just sleeps. Verified on an idle pod with zero traffic: termination took 3,605s exactly.So every gateway pod termination now takes a fixed ~60 minutes regardless of load — every rollout, node drain and scale-down.
maxUnavailable: 0 / maxSurge: 100%means capacity is preserved throughout, so this is cost and slowness rather than risk, but a routine gateway rollout goes from ~1 minute to ~1 hour.Worth making the hook poll Envoy for
downstream_cx_active == 0and exit early, withDRAIN_TIME_SECONDSas a ceiling rather than a floor. Not done here to keep the change to the two values.The Karpenter
core-networkNodePool (which hosts every gateway) hasterminationGracePeriod: 3600s— less than the pod's 3665s. Karpenter then deletes the pod at the start of disruption and grants it only the time remaining to the node deadline, so the drain is truncated to the node's budget rather than the pod's.Observed live on
cortex-dev-virginiawhile testing this change: podspec.terminationGracePeriodSeconds: 3665butmetadata.deletionGracePeriodSeconds: 3599. The gateway PDB also sits atdisruptionsAllowed=0(minAvailable: 80%), and Karpenter loggedDisruptionBlocked — Pdb prevents pod evictions, confirming eviction depends entirely on that deadline path.Existing NodeClaims keep the
terminationGracePeriodthey were created with — raising the NodePool only affects newly created nodes, so long-lived gateway nodes stay mismatched until they are recycled.Prerequisite PR: CerebriumAI/argocd-manifests#1092 raises
core-networkto2h(matching theuser-*pools), leaving 3535s of headroom. Merge and sync that first.Verification
YAML parses (14 docs),
grace > draininvariant asserted, diff limited to the two values.go test/go vet ./pkg/reconciler/knativeserving/ingress/...both exit 0. Only the 1.18 manifest is touched — 1.15–1.17 are unused, all clusters run 1.18.0.🤖 Generated with Claude Code