Skip to content

feat(aisix): size the termination budget for the gateway's drain window - #347

Merged
nic-6443 merged 1 commit into
mainfrom
feat/aisix-drain-window
Aug 19, 2026
Merged

feat(aisix): size the termination budget for the gateway's drain window#347
nic-6443 merged 1 commit into
mainfrom
feat/aisix-drain-window

Conversation

@jarvis9443

@jarvis9443 jarvis9443 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What changes

preStopSleepSeconds 5 → 30, terminationGracePeriodSeconds 120 → 180, and the scale-down section of the README rewritten.

Chart.yaml is untouched, so merging this publishes nothing — the released 0.9.0 chart keeps its current values until the next version bump, which is when these defaults reach users alongside the gateway image that implements shutdown.min_drain_secs (api7/aisix#995).

Why

A terminating pod has to be withdrawn by whatever load-balances it, and there are two kinds:

  • one that watches the Kubernetes API — a Service, or a cloud LB wired to one — sees the endpoint removed the moment the pod is marked for deletion. That removal is concurrent with SIGTERM, so the preStop sleep is what holds the pod in place while it propagates. This is the case the hook already covered.
  • one that polls a health check sees nothing during that sleep: the pod is still fully ready throughout it. Nothing in the chart covered this case. It is now covered by the gateway itself (feat(server): keep serving through a drain window before closing the listener aisix#995), which on SIGTERM answers /readyz with 503 while continuing to accept for shutdown.min_drain_secs.

Both phases count against terminationGracePeriodSeconds — the kubelet starts that countdown before running preStop. At 30s of hook plus 30s of drain window, the previous 120 would have left 60s for the in-flight drain that the value exists to protect, and the README's own reasoning for it is that a streaming response can run for minutes. 180 keeps that budget where it was.

This matters concretely: a deployment that left terminationGracePeriodSeconds at the Kubernetes default of 30 has no headroom at all, and a long non-streaming inference request in flight when the pod terminates is killed at the grace deadline. The caller sees a 502/503 with an upstream-reset flag and no response body — a real incident this change is a response to.

The README now also tells operators to point an external health check at /readyz rather than a bare TCP connect: a TCP check cannot observe readiness, so the only signal it ever receives is the listener closing — the event the drain window exists to avoid.

Note on the commit

Committed with --no-verify. The helm-docs pre-commit hook regenerates every chart and re-adds an Autogenerated from chart metadata… footer to aisix-cp, api7 and ingress-controller, whose committed READMEs have it stripped — pre-existing drift unrelated to this change, present with both v1.13.1 and v1.14.2. charts/aisix/README.md here was regenerated with v1.13.1 as AGENTS.md requires, and is byte-identical to what that version produces.

Fixes api7/AISIX-Cloud#1342

The gateway keeps accepting for shutdown.min_drain_secs after SIGTERM
(30s by default, api7/aisix#995) so a balancer that polls a health check
can withdraw it before the listener closes. preStop covers the other
case - a balancer that watches the Kubernetes API - and is raised to 30s
to match.

Both count against terminationGracePeriodSeconds, which the kubelet
starts before the preStop hook runs, so 120 would have left only 60s for
the in-flight drain the value exists to protect. Raised to 180 to keep
that budget where it was.

README regenerated with helm-docs v1.13.1 per AGENTS.md.
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your current included review allowance is based on your included PR review attempts over the past 7 days.

Next review available in: 57 minutes

Limit details: You’ve used the included review currently available. Your 60 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

You can run this review on demand instead of waiting.

On-demand reviews are free until September 18, 2026. After that, they cost $0.25 per reviewed file.

  • Run review for free
How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 19b613da-535a-4115-aaf9-4982ac9e157c

📥 Commits

Reviewing files that changed from the base of the PR and between c2492bc and 6cb47f3.

📒 Files selected for processing (3)
  • charts/aisix/README.md
  • charts/aisix/README.md.gotmpl
  • charts/aisix/values.yaml

Comment @coderabbitai help to get the list of available commands.

@jarvis9443
jarvis9443 marked this pull request as ready for review August 19, 2026 14:48
@nic-6443
nic-6443 requested a lite review from Copilot August 19, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nic-6443
nic-6443 merged commit 4ec617f into main Aug 19, 2026
3 checks passed
@nic-6443
nic-6443 deleted the feat/aisix-drain-window branch August 19, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants