feat(atenet): graceful termination of atenet-router - #774
Merged
Lior Lieberman (LiorLieberman) merged 6 commits intoAug 7, 2026
Merged
Conversation
shrutiyam-glitch
requested review from
Haven Xia (HavenXia) and
Julian Gutierrez Oschmann (juli4n)
August 6, 2026 16:12
Collaborator
Author
|
/retest |
shrutiyam-glitch
requested review from
Lior Lieberman (LiorLieberman) and
Bowei Du (bowei)
August 6, 2026 19:16
2 tasks
Lior Lieberman (LiorLieberman)
left a comment
Collaborator
There was a problem hiding this comment.
Thanks shrutiyam-glitch !
Collaborator
|
LGTM |
Lior Lieberman (LiorLieberman)
merged commit Aug 7, 2026
5f64ba4
into
agent-substrate:main
11 checks passed
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.
Which issue(s) this PR is related to:
Fixes #721
Required for System Upgrade flow (#473)
What this PR does / why we need it:
This PR implements graceful termination and zero-outage rolling updates for
atenet-router, building on the readiness probe and graceful drain patterns established in #719 (atelet).Draining a two-container networking pod (
atenet-routerGo control-plane +envoyC++ proxy dataplane) introduces complex lifecycle interdependencies. This PR resolves the dual-container SIGTERM race, respects Envoy'sfailClosedext_procfilter dependency, preserves parked requests riding out worker pool saturation, and accelerates idle deployments via an event-driven file handshake.1. Event-Driven Dataplane Synchronization (
emptyDirMarker File)Envoy fast-exits by default on SIGTERM. To keep Envoy alive while the Go control-plane orchestrates the drain, we configured an IPC handshake between containers via a pod-shared
emptyDirvolume mounted at/var/run/atenet:/var/run/atenet/drain-completewhen its shutdown sequence finishes.preStopHook: Runswhile [ ! -f /var/run/atenet/drain-complete ]; do sleep 0.5; done.Outcome: Envoy exits as soon as — the drain is done, rather than wasting time in a fixed worst-case sleep. If the router crashes, Kubelet terminates the
preStophook atterminationGracePeriodSeconds: 60—slower cleanup, never a wedge.2. The Multi-Container Shutdown Sequence (
drain.go)Because Kubernetes issues SIGTERM to both containers at once, a coordination state machine ensures Envoy never drops a connection and
ext_procis never stopped prematurely:(
• Flips
/readyz503.• Starts 13s
drain-delay.lifecycle.preStophook:while [ ! -f .../drain-complete ]; do sleep 0.5; done• Kubelet holds SIGTERM back.
EndpointSlice controller begins dropping Old Pod IP.
(
•
ext_proccontinues unparking/routing requests.preStoploop.• Serves active TCP connections.
No new connections arrive at Old Pod.
(
•
/healthcheck/fail•
/drain_listeners?graceful&skip_exit• Polls
/statsfor active downstream connections.• GOAWAY /
Connection: closeon established connections.• In-flight requests keep running.
(
• Calls
extproc.GracefulStop().• Parked request streams finish.
• Still waiting in the
preStoploop.(
ext_procdrain finishes.• Writes
drain-completemarker.• Hard-stops xDS (
Stop()) & exits.preStoploop detects marker file!•
preStopexits 0.• Kubelet sends SIGTERM to Envoy.
• Envoy exits immediately.
Envoy ref: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/operations/draining
Testing & Verification
drain_test.go): Added comprehensive unit tests covering:ext_procstreams within deadline.--drain-timeout.Test script:
hack/verify-atenet-drain.sh/readyz=200,/healthz=200; the instant the pod turned Terminating:/readyz=503while/healthz=200—NotReadybut alive, for the whole drain.preserved file counter: 1 — park → resume → route, served by the Terminating pod during its drain-delay window.
SIGKILL).