Skip to content

spike(proxy): Envoy hot-restart — 3 upgrade strategies + Strategy A impl - #104

Merged
bpalermo merged 2 commits into
mainfrom
spike/proxy-hot-restart
Jun 9, 2026
Merged

bpalermo merged 2 commits into
mainfrom
spike/proxy-hot-restart

Conversation

@bpalermo

@bpalermo bpalermo commented Jun 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Hot-restart the aether-proxy Envoy so bootstrap-config changes and image upgrades preserve in-flight connections (dynamic listeners/clusters/endpoints already update live via xDS — hot restart is specifically for the static bootstrap + binary).

Full design: docs/proposals/001_proxy-hot-restart.md.

Core constraint

Hot restart hands off listen-socket FDs + stats from epoch N → N+1 via a shared /dev/shm (--base-id) and an abstract domain socket in a shared netns. A vanilla image bump deletes/recreates the Pod and shares neither — so each strategy is a different way to arrange that overlap. The existing hostNetwork: true already gives shared netns for free.

Three strategies (documented + compared)

A: in-place binary B: surge two Pods (target) C: dual-Envoy Pod
Upgrades the container image ❌ (Envoy binary only) ✅ ✅
Standing cost 1× 1× (2× only mid-roll) 2× always
Native rollout ✅ ✅ (maxSurge) ❌ (operator + OnDelete)
Spike order 1st (proves handoff) 2nd (goal) future

Strategy A — implemented in this PR

  • Supervisor (agent/internal/proxy/hotrestart): forks Envoy per restart epoch; fsnotify bootstrap-config watch (debounced) self-triggers a hot restart; SIGHUP/SIGUSR1; newest-epoch-death → exit non-zero (k8s recreates pod); graceful shutdown with drain deadline + SIGKILL fallback.
  • agent proxy-supervisor subcommand, plus --install-path so the static supervisor self-copies onto a shared volume from an initContainer — the runtime container stays the Envoy image (which carries Envoy + its shared libs) with the supervisor injected.
  • Chart: proxy.hotRestart.enabled gate (off by default) wires the supervisor entrypoint, the self-install initContainer, a memory /dev/shm emptyDir, and routes Envoy service flags via --envoy-arg.
  • Tests: buildEnvoyCmd args + a lifecycle test driving a stub Envoy through a config-change-triggered hot restart and clean shutdown.

Not in this PR (next steps)

  • talos-main validation: incremented hot_restart_generation, zero dropped connections, stat continuity.
  • Strategy B: maxSurge DaemonSet, hostPath /dev/shm, /run/aether/hotrestart/epoch coordination (+ live-predecessor probe → epoch-0 reset), readiness gate.

Test plan

  • bazel build //agent/... ✅
  • bazel test //agent/internal/proxy/hotrestart/... //agent/internal/cmd/... ✅
  • helm template renders both gate states correctly (off = unchanged direct-Envoy; on = supervisor + initContainer + /dev/shm) ✅
  • Not yet deployed; off by default, so no change to the running proxy.

🤖 Generated with Claude Code

bpalermo and others added 2 commits June 9, 2026 15:40
Spike groundwork for hot-restarting the aether-proxy Envoy without dropping
connections (bootstrap-config changes and binary upgrades). See
docs/proposals/001_proxy-hot-restart.md for the full plan, constraints
(shared /dev/shm + base-id IPC -> supervisor owns both epochs in one
container) and validation/exit criteria.

- docs/proposals/001_proxy-hot-restart.md: spike plan.
- agent/internal/proxy/hotrestart: supervisor scaffold replicating
  hot-restarter.py in Go (epoch fork/exec, SIGHUP hot restart, SIGUSR1
  forward, parent-shutdown timer, newest-epoch-death-is-fatal). fsnotify
  config-watch trigger and graceful-terminate deadline are left as TODOs.
- agent proxy-supervisor cobra subcommand wiring it into the agent binary.

Builds and existing cmd tests pass; not yet wired into the chart.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Expands the hot-restart proposal to compare three deployment/upgrade
strategies and commits to: spike A (in-place Envoy hot restart, no pod
replacement) first, target B (cross-pod surge upgrade) as the goal, C
(dual-Envoy pod + operator) as the future end state.

Strategy A implementation:
- hotrestart supervisor: fsnotify bootstrap-config watch (debounced) that
  self-triggers a hot restart, plus graceful shutdown with a drain deadline
  and SIGKILL fallback. SIGHUP/SIGUSR1 handling and newest-epoch-death-fatal
  as before.
- proxy-supervisor --install-path: the static supervisor self-copies onto a
  shared volume from an initContainer, so the runtime container can stay the
  Envoy image (which carries Envoy + its shared libs) with the supervisor
  injected alongside.
- chart: proxy.hotRestart.enabled gate (off by default) wires the supervisor
  as the proxy entrypoint, the self-install initContainer, a memory /dev/shm
  emptyDir, and routes Envoy service flags through --envoy-arg.
- tests: buildEnvoyCmd args + a lifecycle test driving a stub Envoy through a
  config-change-triggered hot restart and a clean shutdown.

Builds, unit tests, and `helm template` (both gate states) pass. Not yet
deployed; talos-main validation (zero-drop + stat continuity) is the next step.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo bpalermo changed the title spike(proxy): Envoy hot-restart supervisor scaffold + proposal spike(proxy): Envoy hot-restart — 3 upgrade strategies + Strategy A impl Jun 9, 2026
@bpalermo
bpalermo merged commit f097543 into main Jun 9, 2026
10 checks passed
@bpalermo
bpalermo deleted the spike/proxy-hot-restart branch June 9, 2026 23:05
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