Skip to content

refac(gcp): model the data centers of a bootstrap - #625

Open
NJona wants to merge 1 commit into
multi-dc-02-datacenter-secretsfrom
multi-dc-03-datacenter-model
Open

refac(gcp): model the data centers of a bootstrap#625
NJona wants to merge 1 commit into
multi-dc-02-datacenter-secretsfrom
multi-dc-03-datacenter-model

Conversation

@NJona

@NJona NJona commented Jul 31, 2026

Copy link
Copy Markdown
Member

Until now a bootstrapped project was implicitly a single data center: its nodes, gateway IPs, config paths and domains all lived directly on CodesphereEnvironment. Multi-DC needs more than one of each, so this introduces the DataCenter type holding everything that must differ per data center, while project-level state (project, VPC, jumpbox, shared postgres node, registry) stays on the environment.

BuildDataCenters derives the layout from the flags: one entry today, and with --multi-dc a second one that shares the first's PostgreSQL server. The primary data center keeps an empty resource-name suffix, so every name, path and domain a single-DC bootstrap produces is unchanged.

Review notes

Nothing consumes the layout yet — the callers are migrated in the following PRs. Two mechanisms keep that migration safe:

  • ensureDataCenters derives the layout on first use and adopts state a caller passed through the legacy top-level environment fields, so every entry point works whether or not Bootstrap ran first — including infra files written before multi-DC support.
  • mirrorPrimaryDataCenter projects the primary data center back onto those fields before the infra file is written, so cleanup and restart-vms keep reading what they always have. The projection is one-way and never read back.

Part of the oms beta bootstrap-gcp --multi-dc stack (10 PRs). Merge in order; each PR is based on its predecessor.

Until now a bootstrapped project was implicitly a single data center:
its nodes, gateway IPs, config paths and domains all lived directly on
CodesphereEnvironment. Multi-DC support needs more than one of each, so
this introduces the DataCenter type that holds everything which must
differ per data center, while project-level state (project, VPC,
jumpbox, shared postgres node, registry) stays on the environment.

BuildDataCenters derives the layout from the flags: one entry today, and
with --multi-dc a second one that shares the first's PostgreSQL server.
The primary data center keeps an empty resource-name suffix, so every
name, path and domain a single-DC bootstrap produces is unchanged.

Nothing consumes the layout yet — the callers are migrated in the
following commits. Two mechanisms keep that migration safe:

- ensureDataCenters derives the layout on first use and adopts state a
  caller passed through the legacy top-level environment fields, so
  every entry point works whether or not Bootstrap ran first, including
  infra files written before multi-DC support.
- mirrorPrimaryDataCenter projects the primary data center back onto
  those fields before the infra file is written, so cleanup and
  restart-vms keep reading what they always have.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jona Neef <Jona.Neef.97@gmail.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