Skip to content

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

Merged
kvinwang merged 2 commits into
nextfrom
refactor/gateway-listeners-config
Nov 15, 2026
Merged

kvinwang merged 2 commits into
nextfrom
refactor/gateway-listeners-config

Conversation

@kvinwang

@kvinwang kvinwang commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1585.

Breaking: the gateway refuses a config that uses the old listener settings; update gateway.toml together with the gateway image (the image's own entrypoint, which writes it, is updated here).

The gateway's RPC listener was configured at the top level of gateway.toml, and its admin and debug listeners in [core.admin] and [core.debug], mixed with admin auth and a proxy setting. As in the KMS (#1585):

Section Settings Was
[listeners.default] inherited by all, overridable per listener: Rocket settings (workers, keep_alive, log_level, ident, ...), proxy_protocol top level
[listeners.guest] address, tls (with mutual); CVMs register here and peers sync over it top level address, [tls]
[listeners.admin] enabled, address, auth_token, htpasswd_file, insecure_no_auth [core.admin]
[listeners.debug] enabled, address [core.debug] (insecure_enable_debug_rpc)
[core.proxy] insecure_localhost_backend [core.debug]; it governs proxied app traffic, not a listener

The Rocket settings now in [listeners.default] used to apply only to the RPC listener; admin and debug now inherit them too (e.g. workers = 8 instead of the CPU count).

Old locations are refused at startup, naming the new ones, e.g. tls -> listeners.guest.tls, core.admin -> listeners.admin. The helpers that build a listener's config and refuse the old locations move from the KMS to load_config, shared by both.

[core.proxy] (app traffic) and [core.wg] (WireGuard) stay: they are not Rocket listeners.

Updated: the gateway image entrypoint.sh (also used by the full-stack test's current gateway image), tools/dev-stack.sh, the gateway test configs (test-run/e2e/configs, test-run/cluster/lib.sh, test-run/proxy/gwconfig.py), gateway/docs/cluster-deployment.md, docs/dstack-gateway.md and the security best practices.

Testing

  • New test: the default config passes; [tls], [core.admin], [core.debug] insecure_localhost_backend and a top-level proxy_protocol are refused with their new locations.
  • cargo test passes for dstack-gateway (334), dstack-kms (96) and load_config; clippy with the CI flags and cargo fmt --check pass.
  • Each converted test config (e2e/configs/gateway-{1,2,3}.toml, the cluster harness's generated config, the proxy harness's generated config) loads in the new gateway binary: startup gets past config loading and listener setup and stops at WireGuard interface creation, which needs root on this host. The gateway was not run end to end locally, and the gateway e2e CI does not run on a PR stacked on a feature branch; it runs once this reaches next.

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 gateway ran in a CVM from the config the new entrypoint.sh writes ([listeners.guest] with its mutual TLS, [listeners.admin] with the token), with proxy_protocol added to [listeners.guest]: an app CVM registered and brought up WireGuard; the admin listener required the token.

The gateway's RPC listener was configured at the top level of
gateway.toml, and its admin and debug listeners in [core.admin] and
[core.debug], mixed with admin auth and a proxy setting.

Move them, as in the KMS, to [listeners.guest] (address, tls with
mutual), [listeners.admin] (with its auth) and [listeners.debug]
(insecure_enable_debug_rpc becomes enabled), with [listeners.default]
inherited by each: the Rocket settings that were at the top level, and
proxy_protocol. insecure_localhost_backend moves to [core.proxy], since
it governs proxied app traffic. Old locations are refused at startup.

The listener config helpers move from the KMS to load_config, shared by
both. Update the gateway image entrypoint, dev-stack, the gateway test
configs (e2e, cluster, proxy) and docs.

Signed-off-by: Kevin Wang <wy721@qq.com>
Also note that proxy_protocol needs a TCP listener: one bound to a Unix
socket fails to start with it, so it must override an inherited
proxy_protocol = true.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang force-pushed the refactor/gateway-listeners-config branch from 8dfcd94 to dfa1280 Compare November 15, 2026 17:12
@kvinwang
kvinwang merged commit aa8805a into next Nov 15, 2026
23 checks passed
@kvinwang
kvinwang deleted the refactor/gateway-listeners-config branch November 15, 2026 17:33
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>
kvinwang added a commit that referenced this pull request Nov 16, 2026
tc-gw-internal-009 checks that the gateway refuses the old listener
locations (#1587), restarts it with proxy_protocol on the admin listener
(#1582), and checks the admin audit (#1588) and access (#1589) lines.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 16, 2026
The fixture inserted it after the first "[core.proxy]" line, which in
the #1587 gateway.toml ends a comment in [listeners.default], so the
gateway used the system resolver and tc-gw-proxy-prot-005 saw no query.

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