A stopping control plane gives up the lease before it lets its agents go

With the agent server closed rather than drained, the process could exit
before Run's release had reached the store, and the standby waited out the
lease. The lease is now given up first, synchronously, and nothing takes it
again after.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-05 02:31:13 +02:00
1 parent c2b4985abe
commit 964b659849
3 files changed
+82 -4

No files matched your search

+6
View File
@@ -635,6 +635,12 @@ func newServerCmd() *cobra.Command {
log.Info("shutting down")
sctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
// The lease first: a standby polls for it, and every agent
// about to be let go will be refused by a standby that has
// not taken it yet.
if admin != nil && admin.Leadership() != nil {
admin.Leadership().StepDown()
}
if agentSrv != nil {
// Closed, not shut down gracefully: an agent's stream
// never goes idle, so Shutdown would wait out its whole