fix(iac): converge empty tcpProxies and import database networking - #1169
Merged
Conversation
`tcp: []` compiles to `tcpProxies: {}` while Railway serializes a
proxy-less service with no `tcpProxies` key, so a database (or service)
declared private re-planned `Update <name> networking` after every
successful apply. Empty networking maps now normalize away before the
diff.
Database nodes also import their live networking through the same helper
services use, `railway config pull` writes it back as
`db.networking = { tcpProxies: { "5432": {} } }` when a proxy exists, and
a database node without a networking block keeps the exposure it has.
Fixes #1168
`environmentApplyChangeSet` reads `networking` as a sparse patch: a key the
author leaves out stays as Railway has it, and inside `tcpProxies` an entry
keeps or creates a proxy, a `null` entry deletes one, and an unmentioned port
is left alone — so an empty map changes nothing.
Diffing the block as if it were the whole desired state promised three changes
the apply never makes, and re-planned every one of them after each apply:
`tcpProxies` left out, `privateNetworkEndpoint` left out, and `tcpProxies: {}`
against a live proxy.
The plan now diffs the block's effect, so a change is planned only when the
apply will move something, while the change set still carries the block as
written — that is the payload the apply sends, and a `null` entry is how a
proxy gets deleted. `tcpProxies: { "5432": null }` converges once the apply
has removed the proxy, and an empty map warns that it cannot remove one
instead of planning a removal that never lands.
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.
Fixes #1168.
What.
railway config planconverges after a successful apply. A file that declares a database (or service) private no longer re-plansUpdate <name> networkingforever, database nodes import their live networking sorailway config pullwrites a public proxy back asdb.networking = { tcpProxies: { "5432": {} } }, and a database node without anetworkingblock keeps the exposure it has.tcpProxies: { "5432": null }converges once the apply has removed the proxy, andtcpProxies: {}warns that it cannot remove one instead of planning a removal that never lands.Why. Backboard merges a networking change as
servicePatch.networking = change.after, which makes an authored block a sparse patch: a key the author leaves out stays as Railway has it, and insidetcpProxiesan entry keeps or creates a proxy, a per-portnulldeletes one, and an unmentioned port is left alone — so an empty map changes nothing.diff_networkingcompared the block as if it were the whole desired state, so three plans promised work the apply never does and proposed it again after every apply:tcpProxiesleft out,privateNetworkEndpointleft out, andtcpProxies: {}against a live proxy. Backboard also serializes a service with no proxy as notcpProxieskey while the SDK compilestcp: []totcpProxies: {}, and the database import branch built its node without networking at all, so a public proxy on a database was invisible to both the plan andpull.How.
networking_after_applyreplays an authored block over the live one the way backboard merges it, anddiff_networkingplans a change only when that effect differs from what Railway has. The change set still carries the block as written, because that is the payload the apply sends and a per-portnullis what deletes a proxy.normalize_for_diff("networking")drops empty maps, so{ tcpProxies: {} }and absent networking compare equal (services included).tcpProxiesagainst a live proxy raises a warning naming the spelling that removes it, in place of a removal the apply would skip.environment_config_to_graphimports networking for databases through the same helper services use.diff_networkingskips a database whose desired node has nonetworkingkey: the helpers cannot author it, and pulled files only carry it when a proxy exists.railway config pullrendersdb.networking = { ... }after the helper call for databases with a proxy (TypeScript; Python and Go get the same comment form as deploy overrides). Service domains stay out of the file, as for services.Tests.
src/iac/tests.rs: emptytcpProxiesconverges for postgres, redis and a service; an imported database keeps and round-trips its proxy; unauthored database networking is clean against a live proxy; an empty map warns instead of planning a removal, for a database and for a service; a per-portnullplans the removal and plans nothing once the proxy is gone; an omittedtcpProxiesorprivateNetworkEndpointkeeps what Railway has; an explicit public declaration plans the proxy.src/commands/config/mod.rs: pull renders the override line right after the helper call, strips service domains, and writes nothing for a private database.