feat(guest): support multiple gateway clusters - #1060
Open
kvinwang wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the guest/gateway wiring to support multiple independently operated gateway clusters while keeping gateway_urls as the legacy single-cluster failover list. It updates the VMM config/schema, guest system config generation, guest-side gateway registration + WireGuard setup, health checking, and documentation to reflect multiple dstack-wg* interfaces.
Changes:
- Add
cvm.gateway_clustersconfiguration (name/urls/required) with validation in VMM and newGatewayClusterConfigin shared types. - Register each configured cluster independently (separate WireGuard keys, interfaces, caches, and listen ports) and reject overlapping WireGuard addresses.
- Update guest interface reporting and gateway checker logic to handle multiple
dstack-wg*interfaces; document the new configuration.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dstack/vmm/src/config.rs | Adds gateway_clusters to VMM config and validates cluster names/URLs. |
| dstack/vmm/src/app.rs | Includes gateway_clusters in generated sys_config passed into the guest. |
| dstack/guest-agent/src/guest_api_service.rs | Expands interface reporting to include all dstack-wg* interfaces. |
| dstack/dstack-util/src/system_setup.rs | Implements multi-cluster registration, per-cluster key caches, disjoint WG address validation, and per-cluster WireGuard apply. |
| dstack/dstack-util/src/gateway_checker.rs | Updates health checking to consider multiple configured WireGuard interfaces. |
| dstack/dstack-types/src/lib.rs | Adds SysConfig.gateway_clusters and GatewayClusterConfig type. |
| docs/deployment.md | Documents how to configure multiple gateway clusters and constraints. |
Suppressed comments (1)
dstack/dstack-util/src/system_setup.rs:741
- Error messages in this crate are expected to start with lowercase text (see CLAUDE.md logging/error style). This new error starts with an uppercase "Gateway".
if target.urls.is_empty() {
bail!("Gateway cluster {} has no URLs", target.name);
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cvm.gateway_clustersgroups while preservinggateway_urlsas a single-cluster failover listdstack-wg*interfacesCompatibility
Existing
gateway_urlsconfigurations retain their current first-healthy-URL behavior and continue usingdstack-wg0and the legacy key cache.All explicitly configured clusters must use the gateway app identity authorized by the KMS-issued app keys. Different clusters must use disjoint WireGuard addresses.
Tests
cargo check --manifest-path dstack/Cargo.toml -p dstack-util -p dstack-vmm -p dstack-guest-agentcargo test --manifest-path dstack/Cargo.toml -p dstack-util gateway_cargo test --manifest-path dstack/Cargo.toml -p dstack-vmmcargo test --manifest-path dstack/Cargo.toml -p dstack-typescargo test --manifest-path dstack/Cargo.toml -p dstack-guest-agent --no-run