Skip to content

refactor(kms)!: group listener settings under [listeners.*] - #1585

Merged
kvinwang merged 7 commits into
nextfrom
refactor/kms-listeners-config
Nov 15, 2026
Merged

kvinwang merged 7 commits into
nextfrom
refactor/kms-listeners-config

Conversation

@kvinwang

@kvinwang kvinwang commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1582.

Breaking: the KMS refuses a config that uses the old listener sections; update kms.toml together with the KMS image.

The KMS listeners were configured in [rpc], [core.admin], [core.readonly] and [core.onboard]: one at the top level, three under [core] mixed with admin auth and onboarding behavior, each repeating its TLS paths. This groups them under [listeners.*], named after who connects, with a shared default:

Section For Settings Was
[listeners.default] inherited by all, overridable per listener tls, proxy_protocol, Rocket settings (workers, ...) repeated per listener
[listeners.guest] CVMs: all KMS RPCs, incl. key release address, port [rpc]
[listeners.admin] operators, other KMS nodes enabled, address, port, auth_token, auth_token_hash, htpasswd_file, insecure_no_auth [core.admin]
[listeners.public] deployers, verifiers: read-only RPCs enabled, address, port [core.readonly] (unreleased)
[listeners.onboard] the setup page before keys exist address, port in [core.onboard] (enabled and onboarding options stay there)

The onboard listener serves plain HTTP: it runs before the KMS has certificates, so it does not inherit the default tls, and it does not support proxy_protocol.

The top-level [default] section is dropped. The config is loaded un-nested, so Rocket never read it: the KMS ran with Rocket's own defaults (workers = CPU count, keep_alive = 5, ident = Rocket), not the values written there. Only ident = "DStack KMS" moves to [listeners.default], so responses now carry Server: DStack KMS instead of Server: Rocket; the others stay unset, keeping the effective values.

Old locations are refused. A config that sets [rpc], [core.admin], [core.onboard] address/port/tls, [default], or a Rocket setting at the top level of a config file (such as log_level or limits, which the old guest and onboard listeners read from there) fails at startup with e.g. the config sets listener settings at their old locations; move them: rpc -> listeners.guest, core.admin -> listeners.admin. kms.toml, loaded first as the defaults, has none of them, so one present was set by the operator; a top-level key counts only if a config file set it, since Rocket's own defaults are always present there.

Generators. Updated where they run the KMS built from this repo: tools/dev-stack.sh, dstack-app/entrypoint.sh, the KMS tutorials, and the full-stack test (which renders the old sections only for its KMS 0.5.8 stage, via --legacy-config). dstackup (dstack-cli-core, default KMS 0.5.11) and the dstack-app composes with their deploy scripts deploy pinned older KMS images and keep the old sections; they must switch when those images are bumped.

kms.toml, the KMS README (new "Listeners" section), docs/deployment.md, the RC runbook and the security best practices use the new names.

Testing

  • cargo test -p dstack-kms --all-features passes (96 tests), as do clippy with the CI flags and cargo fmt --check. New test: each old location is refused, naming its new one; the default config and [core.onboard] options pass.
  • The full-stack renderer produces the new sections by default and the old ones with --legacy-config.
  • A local dev KMS (auth_api = "dev", enforce_self_authorization = false, attest_rpc_cert = false):
Config Result
[listeners.default] with tls and proxy_protocol = true; admin overrides proxy_protocol = false; public enabled guest, admin and public bind with TLS. Guest and public drop a request without a PROXY header and serve one with it; admin serves without a header and drops one with it
auth_token in [listeners.admin] Admin.ClearImageCache: 401 without a token or with a wrong one, 200 with it
Admin enabled, no credential refused: admin API is enabled but no credential is configured; set listeners.admin.auth_token, ...
[listeners.admin] enabled = false refused: no key handover path, naming [listeners.admin] enabled = true
[rpc] and [core.admin] port refused: rpc -> listeners.guest, core.admin -> listeners.admin
[core.admin] auth_token refused: core.admin -> listeners.admin
[default] workers = 8 refused: default -> listeners.default
Top-level log_level and [limits] refused: limits -> listeners.default.limits, log_level -> listeners.default.log_level
Default ident Server: DStack KMS on guest and admin; workers, keep_alive, max_blocking unchanged (64, 5, 512 on this host)
Onboarding with [listeners.onboard] the setup page binds on the configured port over plain HTTP

Verified on TDX

Run on the tdxlab TDX host with real TDX CVMs (guest OS dstack 0.6.0), from one local build of #1580, #1582, #1585 and #1587 merged with #1583 and #1588: the official 0.6.3 KMS and gateway images with these binaries (and the gateway's new entrypoint.sh). The KMS ran in a CVM with a local key provider and a webhook auth backend (allow all but one app; this KMS's root epoch 0 registered); haproxy with send-proxy-v2 fronted the guest listeners of the KMS and the gateway.

  • The KMS ran from a kms.toml in the new layout ([listeners.default.tls], [listeners.guest] with proxy_protocol, [listeners.admin] with auth_token_hash, [listeners.public]): all three listeners came up, Server: DStack KMS; the admin listener returned 401 without or with a wrong token and 200 with it.

@kvinwang kvinwang changed the title refactor(kms): group listener settings under [listeners.*] refactor(kms)!: group listener settings under [listeners.*] Nov 15, 2026
@kvinwang
kvinwang force-pushed the refactor/kms-listeners-config branch 2 times, most recently from a9f59b1 to 1bc019f Compare November 15, 2026 04:49
@kvinwang
kvinwang added this pull request to stack #1586 November 15, 2026 04:54
Base automatically changed from feat/kms-proxy-protocol to next November 15, 2026 17:00
The four KMS listeners were configured in [rpc], [core.admin],
[core.readonly] and [core.onboard], the last three mixed with admin
auth and onboarding behavior.

Move their bind settings (enabled, address, port, tls, proxy_protocol)
to [listeners.rpc], [listeners.admin], [listeners.readonly] and
[listeners.onboard]; admin auth stays in [core.admin] and onboarding
behavior in [core.onboard]. The legacy keys are still read and take
precedence: kms.toml, loaded first as the defaults, uses only the new
names, so a legacy key comes from the operator. Generators that target
older KMS images (dstack-cli-core, the dstack-app composes, dev-stack)
keep the legacy names.

Signed-off-by: Kevin Wang <wy721@qq.com>
Rename the listeners rpc -> guest and readonly -> public, after who
connects to them, and add [listeners.default], which each listener
inherits unless its own section overrides it: tls, proxy_protocol and
Rocket settings. The onboard listener, which runs before the KMS has
certificates, does not inherit the default tls.

Drop the top-level [default] section: the config is loaded un-nested, so
Rocket never read it, and the KMS ran with Rocket's own defaults. Its
values are not carried over, which would have changed them.

Signed-off-by: Kevin Wang <wy721@qq.com>
…[listeners.admin]

Drop the compatibility with the old locations: a config that sets
[rpc], [core.admin], [core.onboard] address/port/tls or the top-level
[default] is refused at startup, naming where each moved. kms.toml,
loaded first as the defaults, has none of them, so one present was set
by the operator.

[core.admin] goes entirely: its credentials (auth_token,
auth_token_hash, htpasswd_file, insecure_no_auth) move to
[listeners.admin] with the rest of the admin listener.

Update the generators that run the KMS built from this repo: dev-stack,
the dstack-app entrypoint, the KMS tutorials, and the full-stack test,
which keeps the old sections for its KMS 0.5.8 stage. dstackup and the
dstack-app composes deploy pinned older KMS images and keep them.

Signed-off-by: Kevin Wang <wy721@qq.com>
The dropped [default] section set ident = "DStack KMS" but was never
read, so responses said Server: Rocket. Set it in [listeners.default];
the other values there stay unset, keeping Rocket's defaults.

Signed-off-by: Kevin Wang <wy721@qq.com>
The old guest and onboard listeners read Rocket settings, such as
log_level or limits, from the top level of the config file; the new
listeners read them only from [listeners.*], so those would be silently
ignored. Refuse a top-level key set by a config file, and the
unreleased [core.readonly].

Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Also name listeners.default.tls in the security best practices, which
still referred to rpc.tls.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang force-pushed the refactor/kms-listeners-config branch from 2d21f6a to 8a14e0f Compare November 15, 2026 17:01
@kvinwang
kvinwang merged commit 8af1009 into next Nov 15, 2026
18 checks passed
@kvinwang
kvinwang deleted the refactor/kms-listeners-config branch November 15, 2026 17:12
kvinwang added a commit that referenced this pull request Nov 16, 2026
#1585 and #1587 moved the listener settings of the KMS and the gateway
under [listeners.*] and refuse the old locations at startup, so every
fixture that rendered [rpc], [core.admin], [core.onboard] address/port,
the gateway's top-level address and [tls], [core.admin] or [core.debug]
would fail to start. Render the new sections for the candidate binaries;
the upgrade matrix keeps the old ones for released KMS images. Also
update the configuration inventory.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 16, 2026
Runs the product tests added for launch tickets (#1577), the dstack-mr
lite check and dstack-verifier-wasm (#1555), the SEV-SNP key provider
(#1526), the PROXY header reader (#1582) and the refusal of old listener
settings (#1585, #1587). A row matching no test fails.

Signed-off-by: Kevin Wang <wy721@qq.com>
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