Skip to content

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

Draft
jarvis9443 wants to merge 1 commit into
mainfrom
feat/aisix-drain-window
Draft

feat(aisix): size the termination budget for the gateway's drain window#347
jarvis9443 wants to merge 1 commit into
mainfrom
feat/aisix-drain-window

Conversation

@jarvis9443

Copy link
Copy Markdown
Contributor

Draft — do not merge before the matching gateway image is published. The chart's appVersion pins the image tag, and the README below describes shutdown.min_drain_secs, which lands in api7/aisix#995. Nothing here sets a new env var, so the manifest itself is safe on the current image; only the documentation would be ahead of it.

What changes

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

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.

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.

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

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8371499e-2a44-4112-b3aa-63e0f0e87664

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

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.

1 participant