Repository navigation
graceful termination for atelet - #748
Merged
Haven Xia (HavenXia) merged 1 commit intoAug 5, 2026
Merged
Conversation
Shrutiya Mohan (shrutiyam-glitch)
requested review from
Haven Xia (HavenXia) and
Julian Gutierrez Oschmann (juli4n)
August 4, 2026 22:01
Haven Xia (HavenXia)
merged commit Aug 5, 2026
90bd78a
into
agent-substrate:main
13 of 15 checks passed
1 of 2 tasks
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.
What this PR does / why we need it:
ateletpreviously had noSIGTERMhandling —main()ended in a baresvr.Serve(lis), so any pod eviction,DaemonSetrollout, or node drain killed the process instantly, aborting in-flightRun/Checkpoint/RestoreRPCs mid-execution.This PR adopts the same graceful-shutdown pattern
ate-apiuses: onSIGTERM, mark not-ready, stop accepting new RPCs, let in-flight RPCs finish, and force-stop after a deadline.cmd/atelet/main.go:signal.NotifyContext(kept separate from the work ctx so in-flight RPCs aren't cancelled the momentSIGTERMarrives) + a localdrainOnShutdownmirroringateapi's:MarkNotReady→ sleep--drain-delay→GracefulStop()→ forceStop()after--drain-timeout./readyzand/healthzare wired into the metrics server (serverboot.Readiness), so readiness and liveness diverge correctly during the drain.--drain-delay(default0s—ateletis dialed directly by pod IP, no route-drain window is needed) and--drain-timeout(default5m—Checkpoint/Restorestream multi-GiB snapshots to object storage andcan take minutes; force-cancelling one mid-upload crashes the actor).
manifests/ate-install/atelet.yaml:terminationGracePeriodSeconds: 330(drain-delay + drain-timeout + slack — the sum must fit inside the grace period or the kubeletSIGKILLsmid-drain), the drain flags, and/readyzreadiness +/healthzliveness probes.Test Scenarios Considered:
SIGTERMCRASHED(#362)Unavailable→ ateapi retriesTesting:
cmd/atelet/main_test.go): a loopback gRPC server with a blocking handler holds an RPC in-flight across the drain.TestDrainOnShutdownInFlightFinishes— in-flight RPC completes duringGracefulStop; readiness flips to not-ready.TestDrainOnShutdownForceStopsAfterTimeout— an RPC running past drain-timeout is force-cancelled by Stop().hack/install-ate-kind.sh --deploy-atelet, thenkubectl delete podto deliverSIGTERM, with--drain-delay=25stemporarily set to make the window observable):/readyz=200,/healthz=200(old build had no /readyz at all)./readyz=503while/healthz=200for the whole window —NotReadybut alive.Which issue(s) this PR is related to:
Fixes #719
Required for System Upgrade flow (#473)