Skip to content

perf(proxy): ship the supervisor as its own 15 MiB binary instead of the 65 MiB agent (#772) - #790

Merged
bpalermo merged 1 commit into
mainfrom
perf/772-b2-proxy-supervisor-binary
Sep 16, 2026
Merged

bpalermo merged 1 commit into
mainfrom
perf/772-b2-proxy-supervisor-binary

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Phase B2 of #772 (dep-tree R3). Data-path adjacent: validated on talos-main with a hitless proxy roll + delete-pod check.

perf(proxy): split the hot-restart supervisor out of the agent binary (#772) (B2)

The aether-proxy pod ran the whole 65 MiB agent binary to supervise a child
process. agent proxy-supervisor was a subcommand of //agent/cmd/agent, so the
install-supervisor initContainer self-copied that binary onto the pod's shared
volume and the proxy container ran it as PID 1 — controller-runtime, client-go,
go-control-plane, SPIRE, Gateway API and miekg/dns, none of which it executes.
Its real work (//agent/internal/proxy/hotrestart + //common/readymarker) needs
24 modules and no Kubernetes, no xDS, no SPIRE.

That cost is paid in Go package init(), which runs before main() is entered, on
every supervisor start and every hot-restart epoch. #673 measured the same
binary's init() at >=31% of this container's CPU when it was additionally
re-exec'd as the readiness probe, and carved out //agent/cmd/proxy-ready for it.
The supervisor was the remaining instance of the pattern.

Measured (fastbuild, stripped; go version -m for modules; single-manifest
zstd tarball for the image, so it is the real pull cost):

binary //agent/cmd/proxy-supervisor 16,153,100 B (15.4 MiB), 24 modules
//agent/cmd/agent 68,418,284 B (65.2 MiB), 105 modules
-> -52,265,184 B (-49.8 MiB, -76.4%), -81 modules per proxy pod

image proxy-supervisor 8,188,416 B (7.81 MiB)
agent 22,928,384 B (21.87 MiB)
-> -14,739,968 B (-14.06 MiB, -64.3%)

What changed:

  • New //agent/cmd/proxy-supervisor binary; the cobra command moves to
    //agent/internal/supervisorcmd behind New(version), with per-call flag state
    instead of package-level vars so the binary and the alias cannot share it.
    The only heavy coupling was supervisor.go:56 manager.SetupLogging — its one
    heavy act (ctrl.SetLogger) is meaningless in a process with no
    controller-runtime manager, so it is log.Named(log.NewLogger(debug), name)
    from //common/log (0 external modules). Log output is unchanged. main.go uses
    //common/signals (perf: drop controller-runtime from cni-install and prober (25→5 MiB, 40→15 MiB) via common/signals + slog (#772) #777) rather than ctrl.SetupSignalHandler(), same semantics.
    Every flag name and default is unchanged — the chart passes them literally.

  • agent proxy-supervisor is KEPT as a deprecated alias for one release. A
    forward rolling upgrade does not need it: the initContainer's image and the
    proxy container's command change atomically within one chart revision, and
    supervisor-bin is a per-pod emptyDir, so a surged-in successor stages its
    own binary and no old/new pair ever shares one. ROLLBACK does: helm rollback
    to a chart predating this re-issues agent proxy-supervisor --install-path=…
    against the deployed agent image, and without the alias that initContainer
    dies on "unknown command" and the rollback silently fails to take effect on
    the proxy DaemonSet — during an incident, which is when rollbacks happen. It
    costs nothing: hotrestart is agent-internal code the agent already linked, so
    the agent stays 105 modules / 65.2 MiB. The /proxy-ready tars_layer stays on
    the agent image for the same window; both are marked for removal together.

  • New multi-arch image //agent/cmd/proxy-supervisor:proxy-supervisor_image
    (ghcr.io/bpalermo/aether/proxy-supervisor), carrying /proxy-ready as an extra
    layer. container_structure_test asserts both binaries and the absence of
    /agent. Wired into //charts/aether AETHER_IMAGES (that alone digest-pins the
    values.yaml placeholder and publishes it — publish.yaml needs no new step),
    //tools/buildid:release_build_ids (it is PID 1 of the proxy container, so the
    continuous profiler needs its symbols under a unique build-ID), the Makefile
    load/push targets, and every kind harness that pre-loads images (e2e.yaml's
    image_load loop, docker save list, both kind load loops and both helm install
    lines; e2e/multicluster_{config,replicator,waypoint}.sh).

  • Chart: the initContainer runs proxy.supervisor.image with no subcommand
    argv, and the proxy container's command loses the proxy-supervisor word.
    proxy-ready is untouched, probe timings are untouched. The values.yaml note
    that this DaemonSet "is COUPLED TO THE AGENT IMAGE" is retired — it no longer
    is. Chart 0.92.21 -> 0.92.22.

  • Guards, because the whole value of this binary is what it does not link:
    //agent/cmd/proxy-supervisor:deps_test scans the linked ELF for
    controller-runtime / client-go / apimachinery / gateway-api / go-control-plane
    / go-spiffe / miekg-dns and enforces a 24 MiB bloat ceiling (with a control
    test that the scan is not vacuous); scripts/check-proxy-supervisor-deps.sh is
    the build-graph half, wired into ci.yaml and main.yaml beside the existing
    proxy-ready guard. //agent/internal/supervisorcmd:supervisorcmd_test gains
    TestFlagsCoverTheChartContract, which reads the actual DaemonSet template and
    asserts every flag the chart passes is defined — the split had to preserve
    them byte-for-byte, and the failure mode otherwise is the whole proxy fleet
    exiting on "unknown flag" at rollout time.

Verification: bazel build //... //test/e2e:e2e_test; bazel test //...
(107/107 pass); bazel run //:format.check; bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...; bazel run //:gazelle no
churn; bazel mod tidy idempotent; scripts/go-deps-audit.sh exit 0;
check-proxy-ready-deps.sh and check-proxy-supervisor-deps.sh both OK;
//tools/buildid:release_build_ids all-distinct. helm template before/after
diffs exactly and only: the chart version label, the initContainer image
(agent -> proxy-supervisor), the two removed proxy-supervisor argv words, and
comments. Smoke-tested both entrypoints: the new binary self-installs 16 MiB,
the alias warns and still self-installs 68 MiB.

CLUSTER VALIDATION (data-path adjacent — the supervisor drives hot restarts).
Needs a hitless proxy roll plus a delete-pod check on talos-main. Watch:

  • handoff duration per node (expect the usual 23-26 s; the 09-06 profiling
    pass measured a roll at exactly zero prober errors — anything above that is
    this change);
  • ready-marker transitions: the successor must HOLD readiness until it is the
    live epoch, so maxUnavailable:0 keeps the predecessor serving;
  • aether_supervisor_* counters keyed by k8s.node.name — no wedge, no
    unexpected epoch churn, and the OTLP push must still arrive (telemetry
    setup moved packages);
  • the external prober SLI across the roll: http_error and timeouts must stay
    at the no-roll baseline on both mesh and mesh_dns targets;
  • delete-pod: proxy-supervisor: shutdown admin probe runs on the already-cancelled ctx, so SIGTERM may never drain Envoy (needs reproduction) #771's --termination-grace fallback still drains Envoy when no
    successor can appear.
    The initContainer is the new failure surface: if the proxy-supervisor image is
    missing from the registry it CrashLoopBackOffs, and maxUnavailable:0 correctly
    keeps the old pods serving — check kubectl -n aether-system describe ds aether-proxy before concluding anything about the data path.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…#772) (B2)

The aether-proxy pod ran the whole 65 MiB agent binary to supervise a child
process. `agent proxy-supervisor` was a subcommand of //agent/cmd/agent, so the
install-supervisor initContainer self-copied that binary onto the pod's shared
volume and the proxy container ran it as PID 1 — controller-runtime, client-go,
go-control-plane, SPIRE, Gateway API and miekg/dns, none of which it executes.
Its real work (//agent/internal/proxy/hotrestart + //common/readymarker) needs
24 modules and no Kubernetes, no xDS, no SPIRE.

That cost is paid in Go package init(), which runs before main() is entered, on
every supervisor start and every hot-restart epoch. #673 measured the same
binary's init() at >=31% of this container's CPU when it was additionally
re-exec'd as the readiness probe, and carved out //agent/cmd/proxy-ready for it.
The supervisor was the remaining instance of the pattern.

Measured (fastbuild, stripped; `go version -m` for modules; single-manifest
zstd tarball for the image, so it is the real pull cost):

  binary   //agent/cmd/proxy-supervisor  16,153,100 B (15.4 MiB), 24 modules
           //agent/cmd/agent             68,418,284 B (65.2 MiB), 105 modules
           -> -52,265,184 B (-49.8 MiB, -76.4%), -81 modules per proxy pod

  image    proxy-supervisor   8,188,416 B (7.81 MiB)
           agent             22,928,384 B (21.87 MiB)
           -> -14,739,968 B (-14.06 MiB, -64.3%)

What changed:

- New //agent/cmd/proxy-supervisor binary; the cobra command moves to
  //agent/internal/supervisorcmd behind New(version), with per-call flag state
  instead of package-level vars so the binary and the alias cannot share it.
  The only heavy coupling was supervisor.go:56 `manager.SetupLogging` — its one
  heavy act (ctrl.SetLogger) is meaningless in a process with no
  controller-runtime manager, so it is `log.Named(log.NewLogger(debug), name)`
  from //common/log (0 external modules). Log output is unchanged. main.go uses
  //common/signals (#777) rather than ctrl.SetupSignalHandler(), same semantics.
  Every flag name and default is unchanged — the chart passes them literally.

- `agent proxy-supervisor` is KEPT as a deprecated alias for one release. A
  forward rolling upgrade does not need it: the initContainer's image and the
  proxy container's command change atomically within one chart revision, and
  `supervisor-bin` is a per-pod emptyDir, so a surged-in successor stages its
  own binary and no old/new pair ever shares one. ROLLBACK does: `helm rollback`
  to a chart predating this re-issues `agent proxy-supervisor --install-path=…`
  against the deployed agent image, and without the alias that initContainer
  dies on "unknown command" and the rollback silently fails to take effect on
  the proxy DaemonSet — during an incident, which is when rollbacks happen. It
  costs nothing: hotrestart is agent-internal code the agent already linked, so
  the agent stays 105 modules / 65.2 MiB. The /proxy-ready tars_layer stays on
  the agent image for the same window; both are marked for removal together.

- New multi-arch image //agent/cmd/proxy-supervisor:proxy-supervisor_image
  (ghcr.io/bpalermo/aether/proxy-supervisor), carrying /proxy-ready as an extra
  layer. container_structure_test asserts both binaries and the absence of
  /agent. Wired into //charts/aether AETHER_IMAGES (that alone digest-pins the
  values.yaml placeholder and publishes it — publish.yaml needs no new step),
  //tools/buildid:release_build_ids (it is PID 1 of the proxy container, so the
  continuous profiler needs its symbols under a unique build-ID), the Makefile
  load/push targets, and every kind harness that pre-loads images (e2e.yaml's
  image_load loop, docker save list, both kind load loops and both helm install
  lines; e2e/multicluster_{config,replicator,waypoint}.sh).

- Chart: the initContainer runs `proxy.supervisor.image` with no subcommand
  argv, and the proxy container's command loses the `proxy-supervisor` word.
  proxy-ready is untouched, probe timings are untouched. The values.yaml note
  that this DaemonSet "is COUPLED TO THE AGENT IMAGE" is retired — it no longer
  is. Chart 0.92.21 -> 0.92.22.

- Guards, because the whole value of this binary is what it does not link:
  //agent/cmd/proxy-supervisor:deps_test scans the linked ELF for
  controller-runtime / client-go / apimachinery / gateway-api / go-control-plane
  / go-spiffe / miekg-dns and enforces a 24 MiB bloat ceiling (with a control
  test that the scan is not vacuous); scripts/check-proxy-supervisor-deps.sh is
  the build-graph half, wired into ci.yaml and main.yaml beside the existing
  proxy-ready guard. //agent/internal/supervisorcmd:supervisorcmd_test gains
  TestFlagsCoverTheChartContract, which reads the actual DaemonSet template and
  asserts every flag the chart passes is defined — the split had to preserve
  them byte-for-byte, and the failure mode otherwise is the whole proxy fleet
  exiting on "unknown flag" at rollout time.

Verification: `bazel build //... //test/e2e:e2e_test`; `bazel test //...`
(107/107 pass); `bazel run //:format.check`; `bazel build --config=lint
--@aspect_rules_lint//lint:fail_on_violation //...`; `bazel run //:gazelle` no
churn; `bazel mod tidy` idempotent; `scripts/go-deps-audit.sh` exit 0;
check-proxy-ready-deps.sh and check-proxy-supervisor-deps.sh both OK;
//tools/buildid:release_build_ids all-distinct. `helm template` before/after
diffs exactly and only: the chart version label, the initContainer image
(agent -> proxy-supervisor), the two removed `proxy-supervisor` argv words, and
comments. Smoke-tested both entrypoints: the new binary self-installs 16 MiB,
the alias warns and still self-installs 68 MiB.

CLUSTER VALIDATION (data-path adjacent — the supervisor drives hot restarts).
Needs a hitless proxy roll plus a delete-pod check on talos-main. Watch:
  - handoff duration per node (expect the usual 23-26 s; the 09-06 profiling
    pass measured a roll at exactly zero prober errors — anything above that is
    this change);
  - ready-marker transitions: the successor must HOLD readiness until it is the
    live epoch, so maxUnavailable:0 keeps the predecessor serving;
  - aether_supervisor_* counters keyed by k8s.node.name — no wedge, no
    unexpected epoch churn, and the OTLP push must still arrive (telemetry
    setup moved packages);
  - the external prober SLI across the roll: http_error and timeouts must stay
    at the no-roll baseline on both mesh and mesh_dns targets;
  - delete-pod: #771's --termination-grace fallback still drains Envoy when no
    successor can appear.
The initContainer is the new failure surface: if the proxy-supervisor image is
missing from the registry it CrashLoopBackOffs, and maxUnavailable:0 correctly
keeps the old pods serving — check `kubectl -n aether-system describe ds
aether-proxy` before concluding anything about the data path.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the perf/772-b2-proxy-supervisor-binary branch from aed7722 to 4db5716 Compare September 16, 2026 01:35
@bpalermo
bpalermo merged commit ab630f2 into main Sep 16, 2026
20 checks passed
@bpalermo
bpalermo deleted the perf/772-b2-proxy-supervisor-binary branch September 16, 2026 01:44
bpalermo added a commit that referenced this pull request Sep 20, 2026
#772/#790 split the hot-restart supervisor into its own image and its own
chart value, `proxy.supervisor.image`, whose values.yaml defaults are
release-time substitution placeholders. It updated the workflow and the
three multicluster harnesses to build, kind-load and `--set` the new image
-- but not e2e/uds.sh. So the placeholder went to the kubelet verbatim and
the aether-proxy DaemonSet pod sat in Init:InvalidImageName, which is why
the `uds` nightly job has answered 000000 for its very first assertion
every night since 2026-09-16 while `waypoint` and `replicator` stayed green.

Mirror the sibling harnesses exactly: proxy-supervisor in IMAGES, its
:image_load target in build_images, and $(img proxy.supervisor
proxy-supervisor) on the helm install.

Fixes #860


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5 <[email protected]>
bpalermo added a commit that referenced this pull request Sep 30, 2026
…lias, supervisor and mesh-dns --readiness-check (#1080)

- Drop the `agent proxy-supervisor` alias (#772/#790) and the /proxy-ready
  layer on the agent image that only it read; the chart stages proxy-ready
  from the proxy-supervisor image. The agent image test now asserts
  /proxy-ready is absent, and a test pins the subcommand as retired.
- Drop the supervisor's deprecated --readiness-check (#673/#775); replace
  TestDeprecatedFlagsStayRegistered with TestRetiredFlagsGone.
- Drop mesh-dns's deprecated --readiness-check (#683), with a matching
  TestRetiredFlagsGone, and fix the stale meshdns.WithReadyMarker comment.
- Update docs/configuration.md, CLAUDE.md, AGENTS.md and common/readymarker
  comments accordingly. charts/ is intentionally untouched.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5.5 <[email protected]>
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