Skip to content

feat(supervisor): export the restart epoch to each Envoy child (#1333) - #1366

Merged
bpalermo merged 4 commits into
mainfrom
feat/supervisor-restart-epoch-env
Oct 7, 2026
Merged

bpalermo merged 4 commits into
mainfrom
feat/supervisor-restart-epoch-env

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Part of #1333

What changes

The proxy supervisor now starts every Envoy child with AETHER_RESTART_EPOCH=<n> in its environment, where n is the --restart-epoch value passed to that same child. It is the number Envoy exports as envoy_server_hot_restart_epoch.

Nothing reads the variable yet. The access-log change for #1333 (a separate pull request, mergeable in either order) reads it with %ENVIRONMENT(AETHER_RESTART_EPOCH)%, so each row names the proxy generation that wrote it.

How

  • buildEnvoyCmd sets cmd.Env to the supervisor's own environment plus this one variable. The child inherited the supervisor's environment before (no cmd.Env), and still gets all of it.
  • An AETHER_RESTART_EPOCH the supervisor itself inherited is removed before the new one is added, so there is exactly one entry and a stale value cannot win.
  • buildEnvoyCmd is the only place a child is built, and hotRestart is its only caller. The first start, an in-pod hot restart and a cross-pod handoff (attach at predecessor + 1) therefore all export the number that is on the command line.
  • validateConfig (envoy --mode validate) is unchanged: it is not a serving child and has no epoch.

Tests

  • TestChildEnv: the helper, including a stale value, several stale values, and a variable that only shares the prefix.
  • TestBuildEnvoyCmdExportsRestartEpoch: the command the supervisor builds carries the epoch once, equal to its --restart-epoch, with the inherited environment intact.
  • TestEnvoyChildSeesItsRestartEpoch: real child processes, with AETHER_RESTART_EPOCH=99 in the supervisor's environment, record what they see. First start and in-pod hot restart give 0 0 and 1 1; a cross-pod handoff over a predecessor at epoch 6 gives 7 7.

Measured: with the one production line removed, the last two tests fail ("0 99", "1 99" and "7 99"); with it, the package passes, also under --config=race.

//agent/cmd/proxy-supervisor:deps_test and scripts/check-proxy-supervisor-deps.sh pass; no dependency was added (strings and strconv only). No chart change.

Not verified here: a real Envoy reading the variable. That is covered by the live test in the access-log pull request.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Copilot AI balanced review requested due to automatic review settings October 7, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An allowed extra restart-epoch argument can make the exported value differ from Envoy’s effective epoch.

2 open findings
What changed in this PR

Exports each Envoy child’s restart epoch for future per-generation access-log attribution under #1333.

Changes:

  • Adds a sanitized AETHER_RESTART_EPOCH child environment variable.
  • Tests initial starts, hot restarts, handoffs, and stale environment values.
  • Registers the new test file with Bazel.
File Description
agent/​internal/​proxy/​hotrestart/​supervisor.go Exports the child epoch.
agent/​internal/​proxy/​hotrestart/​childenv_test.go Tests epoch propagation.
agent/​internal/​proxy/​hotrestart/​BUILD.bazel Includes new tests.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 22:48
@bpalermo
bpalermo force-pushed the feat/supervisor-restart-epoch-env branch from dded315 to ea92ef9 Compare October 7, 2026 22:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A failing subprocess test can leave the supervisor and child processes running.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Every Envoy child is now started with AETHER_RESTART_EPOCH set to its own
--restart-epoch value, so an access-log format can name the generation that
wrote a row with %ENVIRONMENT(AETHER_RESTART_EPOCH)%.

The child keeps the supervisor's whole environment, as before. Any
AETHER_RESTART_EPOCH the supervisor itself inherited is dropped first, so a
stale value can never name the wrong generation.

There is one place a child is built (buildEnvoyCmd, called only from
hotRestart), so the first start, an in-pod hot restart and a cross-pod
handoff at predecessor+1 all get the number passed on the command line.

Part of #1333

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 7, 2026 23:07
@bpalermo
bpalermo force-pushed the feat/supervisor-restart-epoch-env branch from ea92ef9 to a140ccb Compare October 7, 2026 23:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation preserves inherited variables, prevents stale epoch duplication, and has focused lifecycle coverage.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 7, 2026 23:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation and coverage are sound; the identified documentation inconsistencies are non-blocking.

2 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 7, 2026 23:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is correct and comprehensively tested; the remaining feedback is documentation-only.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@bpalermo
bpalermo merged commit 8f28b63 into main Oct 7, 2026
30 checks passed
@bpalermo
bpalermo deleted the feat/supervisor-restart-epoch-env branch October 7, 2026 23:50
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.

2 participants