dstack-cloud: honor gcp_config.private_ip (bind static internal IP)#709
Merged
Merged
Conversation
GcpConfig had no private_ip field, so a private_ip set in app.json was silently dropped on load (and prepare/deploy rewrite app.json, stripping it), and the VM was never created with --private-network-ip — it always got an ephemeral internal IP. That breaks any service addressed by a stable internal IP across remove/deploy (e.g. an in-VPC KMS whose TLS cert SAN / kms_urls pin a fixed address). Add the field and pass --private-network-ip (defaulting --subnet=default when the user didn't name one, since gcloud requires the subnet for a custom internal IP).
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
GcpConfighas noprivate_ipfield, so aprivate_ipset in an app'sapp.jsonis silently dropped when the config is loaded (from_dictfilters to known dataclass fields), andprepare/deploythen rewriteapp.jsonstripping the field. The VM is also never created with--private-network-ip, so it always gets an ephemeral internal IP.This breaks any deployment that addresses a VM by a stable internal IP across
remove+deploy— e.g. an in-VPC KMS whose TLS cert SAN /kms_urlspin a fixed RFC1918 address. After a redeploy the IP changes and clients can no longer reach (or verify) the service.Fix
private_ip: str = ""toGcpConfig(and toget_template()).create_args, whenprivate_ipis set, pass--private-network-ip=<ip>(and default--subnet=defaultwhen the user didn't name a subnet, since gcloud requires the subnet for a custom internal IP).Reserve the address first, e.g.:
then set
gcp_config.private_ip = "10.128.15.220"inapp.json. The VM now keeps that address across redeploys.Testing
Deployed two CVMs with reserved static IPs (
10.128.15.220/10.128.15.230);deployoutput's Internal IP matched the reserved addresses, and they stayed stable acrossremove+deploy. Without the patch the same configs produced ephemeral IPs.Backwards compatible: when
private_ipis empty (the default), behavior is unchanged.