← Back to Pull requests

Drain gateway connections without curl #1485

Open
unknown opened this pull request with 189 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 14, 2026 20:04 UTC
Author

The gateway's preStop hook calls curl, but the Envoy image doesn't include it. The hook sleeps without starting a drain, leaving keep-alive clients to discover closed connections at shutdown. We saw the same disconnects during both unchanged and upgraded gateway rollouts while testing #1481.

Add a small Go helper, built as a standalone ko image and mounted read-only into the gateway using an image volume. Keep Envoy's upstream image unchanged so its patch updates remain independent of the helper build. preStop invokes /drain-helper/ko-app/drain directly—no shell, copying, or init container.

The helper uses context.WithTimeout with DRAIN_TIME_SECONDS (default 15 seconds) to bound the whole hook. It POSTs to the loopback admin endpoint, checks for HTTP 200, and waits for the remainder of the drain window, including on failure.

This uses image volumes, stable in Kubernetes 1.36, which the next Knative release targets.

Checked mounting and execution on kind 1.35 with ImageVolume enabled and containerd 2.2. The mounted helper ran as UID 65534, triggered Connection: close, waited for the configured duration, and completed the actual preStop hook during pod deletion. The 1.36 kind node image wasn't available for a direct check. The initial helper also passed focused unit tests and lint.

``release-note
Kourier gateways now initiate graceful connection draining during shutdown without depending on curl in the Envoy image. The helper is supplied through a Kubernetes image volume.
``

Diff: 189 lines (+141 / -48) across 2 files Reviewer: linkvt Review duration: 3998m
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 189 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.314
Real PR Conversation Timeline
1 comments
"Review active on #1485"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 35.9% (MEDIUM) · Higher = larger blast radius
35.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 46.7% · Lower = rushed or shallow review
46.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 19.1% · Safe to merge
19.1%