Skip to content

fix(supervisor): --envoy-arg rejects at startup what the pinned Envoy would reject at every fork (#1407, #1408, #1409) - #1433

Merged
bpalermo merged 3 commits into
mainfrom
fix/supervisor-envoy-arg-spellings
Oct 8, 2026
Merged

bpalermo merged 3 commits into
mainfrom
fix/supervisor-envoy-arg-spellings

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Closes #1407
Closes #1408
Closes #1409

Follow-up to #1399. The supervisor checks --envoy-arg once at startup. This PR makes that check refuse three more kinds of argument, each decided from what the pinned Envoy does.

What changed

Nothing under charts/ changed. No dependency was added.

Design

The one list from #1399, reservedEnvoyFlags in agent/internal/proxy/hotrestart/envoyargs.go, stays the single place for refused flags. Each new entry carries conflict: true, which means "the supervisor does not pass this flag; it is refused for what it does". Both drift tests from #1399 are kept:

  • TestEveryFlagTheSupervisorPassesIsReserved is unchanged.
  • TestReservedFlagsAreAllPassedOrAliases now holds a conflict entry to the opposite rule (the supervisor passes none of its spellings), so neither kind can be labelled as the other.

The allowed-once flags are a second, small table (onceEnvoyFlags). TestChartEnvoyArgFlagsAreAllowedOnce reads the flags off the chart template and fails if the chart passes one that is not in it.

New test target //agent/test/envoyargs runs the same arguments through the pinned Envoy and through the check. A pin bump that changes Envoy's parser (for example, one that starts to accept --flag=value) fails there. It takes 4.3 s.

Measured on the pinned Envoy

Binary: the one behind //agent/test/envoybin:envoy_bin (8eafebb8…/1.40.0-dev). Parser runs used --mode validate -c <minimal bootstrap>. Handoff runs started two real Envoys with the same --base-id, epoch 0 then epoch 1.

#1407. The = spelling is refused for every flag I tried (17), not for some.

Argument Result
--concurrency=2, --service-node=n1, --service-cluster=x, --log-level=info, --drain-strategy=gradual, --log-format=%v, --component-log-level=upstream:debug, --stats-tag=a:b, --socket-mode=600, --log-path=/dev/null, --local-address-ip-version=v4, --file-flush-interval-msec=100, --config-yaml={}, --disable-extensions=foo, --skip-hot-restart-parent-stats=true PARSE ERROR: Argument: <item> Couldn't find match for argument
-l=info, -linfo the same error
-l info, --log-level info, --concurrency 2 accepted
--service-node -c, --service-node --x=y, --log-format '--base-id=%v' accepted: Envoy reads the next argument as the value, whatever it looks like

#1408. --concurrency values. The "workers" column is /server_info concurrency of a serving Envoy, confirmed by counting wrk:worker_* threads.

Value Envoy Workers The check now
2, 02 accepts 2 accepts
0 accepts 1 (concurrency_ = std::max(1U, value) in options_impl.cc) accepts, counts 1
none (last argument) Missing a value for this argument! refuses
x, 2x, 1.5, 0x2, 2 (trailing space), 4294967296 Couldn't read argument value from string '…' refuses
-l info, --skip-hot-restart-parent-stats as the value Couldn't read argument value from string '-l' refuses
empty string accepts 20 on a 20-CPU machine: the default, as if the flag were absent refuses
-1 accepts, reads it as 4294967295 the validate run did not finish in 30 s refuses
+2, 2 (leading space) accepts 2 refuses: digits only
4294967295 accepts the validate run did not finish in 30 s refuses: the limit is 2147483647

So 0 is not "one per core" and is not an error in Envoy. I kept it legal and made the handoff logic read it as 1, instead of refusing a command line that works today.

#1409. Base id and the other hot-restart flags. Read in the Envoy source at the pin (726d7ac): source/server/options_impl.cc and source/exe/stripped_main_base.cc (configureHotRestarter).

Flag What the source says Measured Class
--use-dynamic-base-id Envoy ignores --base-id and picks a random one. It throws when the restart epoch is above 0. With --base-id 4242, the epoch-0 Envoy chose base id 76596540 (its shared memory was /dev/shm/envoy_shared_memory_765965400). Its epoch-1 successor exited with cannot use --restart-epoch=1 with --use-dynamic-base-id. A successor without the flag looped on hot restart sendmsg() connection refused. reserved
--base-id-path Only writes the base id in use to a file. The file held 4242 after epoch 0 and after epoch 1, and the handoff completed (the parent was terminated by the child). allowed
--disable-hot-restart No hot-restart object is built. Epoch 1 went LIVE next to epoch 0, which was never drained or stopped. reserved
--socket-path The path of the hot-restart socket. The default is the abstract @envoy_domain_socket. A successor on another path looped on connection refused and never initialized. reserved
--socket-mode Not read while the socket path starts with @. Accepted by the parser. allowed
--hot-restart-version, --version, -h / --help Print and throw NoServingException. Exit status 0 at once, in serve mode too. reserved
-- / --ignore_rest The parser ignores what follows. -- --concurrency 1 ran 20 workers. reserved
--skip-hot-restart-parent-stats The child does not ask the parent for stats. Accepted once; twice is Argument already set!. allowed once (the chart's proxy.hotRestart.skipParentStats)
--skip-hot-restart-on-no-parent A child with no parent continues instead of crashing. With no parent and no shared memory, both variants aborted the same way. allowed
--drain-strategy Twice is Argument already set!. allowed once (chart)
--cpuset-threads A no-op now: it logs "now the default behavior". Accepted. allowed
--drain-time-s, --parent-shutdown-time-s, --restart-epoch, --base-id, --admin-address-path, --mode, -c reserved since #1399

envoy --help lists no other admin or drain flag. The admin address comes from the bootstrap.

Red, then green

The new tests in agent/internal/supervisorcmd/flags_test.go and //agent/test/envoyargs use only the existing entry points, so I ran them against main's envoyargs.go and concurrencychange.go first:

  • 7 tests failed, with 67 failing subtests: TestEnvoyArgRejectsSpellingsEnvoyDoesNotParse 8 of 8, TestEnvoyArgRejectsABadConcurrencyValue 8 of 8, TestEnvoyArgRejectsFlagsThatBreakAHandoff 9 of 9, TestEnvoyRefusesWhatTheCheckRefuses 30 of 35 (the other 5 were already refused), TestCheckIsStricterThanEnvoyOnPurpose 12 of 12, plus TestChartEnvoyArgFlagsAreAllowedOnce and the changed line of TestEnvoyArgConcurrencyOnceOnly.
  • With the change, all pass.

The new tests inside the hotrestart package use new unexported names, so they do not compile against main. I did not run those red. Instead I applied three temporary mutations and saw each one caught: --base-id marked conflict and --socket-path unmarked (both caught by TestReservedFlagsAreAllPassedOrAliases, the second also by TestCheckExtraArgsRefusesWhatBreaksAHandoff), and --drain-strategy removed from onceEnvoyFlags (caught by TestChartEnvoyArgFlagsAreAllowedOnce).

The chart still passes

  • TestChartEnvoyArgsPassTheCheck passes. It needed one change: it feeds template source to the check, and the item after --concurrency is the template action {{ . }}, which the new value rule would refuse. The test now stands 2 in for it, and fails if that item stops being a template action.
  • helm template of charts/aether (helm 3.18.4), proxy container --envoy-arg items, run through checkEnvoyArgs in a temporary test (not committed) and through the pinned Envoy in validate mode:
    • default values: -l info --service-cluster aether-proxy --service-node $(NODE_NAME) --service-zone $(ZONE) --drain-strategy gradual. Accepted by both.
    • proxy.concurrency=2, proxy.hotRestart.skipParentStats=true, proxy.hotRestart.hotRestartOnConcurrencyChange=true, proxy.hotRestart.baseId=3, proxy.logLevel=debug, otel.endpoint set: the same plus --concurrency 2 --skip-hot-restart-parent-stats. Accepted by both.
    • the second list with $(NODE_NAME) expanded and an empty $(ZONE): accepted by the check.

Other checks

  • bazel test //agent/test/envoyargs:all //agent/internal/supervisorcmd:all //agent/internal/proxy/hotrestart:all //agent/cmd/proxy-supervisor:all passes, including deps_test. scripts/check-proxy-supervisor-deps.sh passes.
  • The three touched go_test targets pass under --config=race.
  • The lint build with fail_on_violation over //... and make format-check pass. make gazelle changed nothing.

Existing test cases I changed

Four expectations, each because the issue asks for the opposite:

No case was removed.

Limits, and what I did not verify

  • The check still compares every item, because it does not carry Envoy's flag table and so does not know which flags take a value. Envoy does (see the table above). So a value spelled like a refused argument is refused although Envoy would take it: a --service-node named -c, a --log-format that is --x=y or that starts with -l or -c. A value that only contains =, or starts with a dash and a space, is fine.
  • A flag in none of the lists is passed through unchecked. A misspelled flag, or a non-chart flag given twice, still fails at the fork.
  • The check is stricter than Envoy for +2, a leading space, the empty value, negative values and values above 2147483647. Envoy accepts all of them.
  • --socket-path is reserved on the evidence of a mismatch between two Envoys. A deployment that set the same abstract path on every pod from the start would hand off fine and is refused too. I judged the roll that introduces the flag to be the real risk.
  • --skip-hot-restart-on-no-parent: I only measured the case with no shared memory at all. I did not build the case where the shared memory exists and the parent is gone, which is where the flag differs.
  • Not run on a cluster: no kind or talos-main run. The handoff measurements are two Envoys started by hand on a workstation, not through the supervisor.
  • The talos-like values are my reading of the task, not the live release's values.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

… would reject at every fork (#1407, #1408, #1409)

The startup check now refuses, with an error that names the argument:

- a flag and its value in one item (--flag=value, -f=value, -fvalue): the
  pinned Envoy answers "Couldn't find match for argument" for every flag
  (#1407). The error shows the two-item form.
- a --concurrency with a missing or unusable value (#1408). 0 is accepted
  and read as one worker, which is what Envoy runs for it.
- flags the supervisor does not pass but that break a handoff or stop
  Envoy from serving: --use-dynamic-base-id, --disable-hot-restart,
  --socket-path, --hot-restart-version, --version, -h/--help, -- and
  --ignore_rest (#1409). --base-id-path is harmless and stays allowed.
- a second one of any flag the chart passes through --envoy-arg.

//agent/test/envoyargs runs the same arguments through the pinned Envoy,
so a pin bump that changes the parser fails a test.

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 8, 2026 13:52

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

The remediation message and documentation prescribe an invalid extra value for valueless Envoy flags.

2 open findings
What changed in this PR

Strengthens proxy-supervisor startup validation so invalid Envoy arguments fail before the first fork.

Changes:

  • Rejects unsupported argument spellings, invalid concurrency values, duplicates, and handoff-breaking flags.
  • Aligns concurrency handling with pinned Envoy behavior.
  • Adds unit and pinned-Envoy tests plus documentation.
File Description
docs/​configuration.md Documents validation rules and limitations.
agent/​test/​envoyargs/​envoyargs_test.go Verifies behavior against pinned Envoy.
agent/​test/​envoyargs/​BUILD.bazel Defines the pinned-Envoy test target.
agent/​internal/​supervisorcmd/​supervisor.go Updates validation guidance and help text.
agent/​internal/​supervisorcmd/​flags_test.go Expands CLI and chart validation tests.
agent/​internal/​proxy/​hotrestart/​envoyargs.go Implements argument validation.
agent/​internal/​proxy/​hotrestart/​envoyargs_test.go Tests argument parsing and rejection rules.
agent/​internal/​proxy/​hotrestart/​concurrencychange.go Aligns concurrency extraction with Envoy.
agent/​internal/​proxy/​hotrestart/​concurrencychange_test.go Covers new concurrency semantics.

🧠 Review effort: Balanced


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

Comment thread docs/configuration.md Resolved
…o go alone

The spelling error advised two items for every flag. For a flag that takes
no value the second item is refused by Envoy too, so the advice for the
pinned Envoy's switch flags is now the flag alone. //agent/test/envoyargs
checks each of them against the binary.

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 8, 2026 13:58

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.

🔵 Needs a closer look

The startup gate directly affects every proxy launch and hot-restart handoff, while end-to-end cluster behavior was not verified.

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.

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 validation behavior is consistent, documented, and comprehensively tested against the pinned Envoy binary.

0 open findings

🧠 Review effort: Balanced


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

@bpalermo
bpalermo merged commit 72b6493 into main Oct 8, 2026
31 checks passed
@bpalermo
bpalermo deleted the fix/supervisor-envoy-arg-spellings branch October 8, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants