Skip to content

feat(helm): add shared db-config ConfigMap - #1293

Merged
andrzejfudro merged 4 commits into
mainfrom
feat/shared-db-config
Oct 23, 2026
Merged

andrzejfudro merged 4 commits into
mainfrom
feat/shared-db-config

Conversation

@andrzejfudro

@andrzejfudro andrzejfudro commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the shared db-config ConfigMap: the single place XMC services will get their database settings from, for both Spanner and PostgreSQL. This is the first PR of the storage-factory stack (see below). On its own it changes no behaviour: no service reads db-config yet.

Key Changes

  • deploy/helm/values.yaml: adds a database: block with backend ("spanner" by default, or "postgres") and postgres.* settings. host, user, essDatabase and xidDatabase are empty; only port (5432) and sslMode (verify-full) have defaults. There is no password field, because db-config is a plain ConfigMap.
  • deploy/helm/templates/db-config.yaml: renders DB_BACKEND plus the selected backend's settings:
    • spanner: SPANNER_ESS_DATABASE, SPANNER_XID_DATABASE, SPANNER_QUOTA_PROJECT_ID, from the same values the per-service ConfigMaps use;
    • postgres: POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_ESS_DATABASE, POSTGRES_XID_DATABASE, POSTGRES_SSLMODE. The render fails if host, user or a database name is missing.
    • Any other database.backend value fails the render.
  • deploy/helm/templates/_helpers.tpl: adds xmanager-cloud.dbBackend, plus xmanager-cloud.essSpannerDatabase / xmanager-cloud.xidSpannerDatabase for the Spanner database paths.
  • Workloads: the actuator, dashboard-service, ess, health-service, log-monitor, reconciler, rod and xid deployments load db-config with envFrom.
  • Tests (test/helm/db_config_test.py): the default render matches the ESS and XID ConfigMaps. Also covered:
    • Spanner overrides;
    • the PostgreSQL keys, their defaults, and the render failure for each missing setting;
    • an unknown backend;
    • the envFrom wiring of all 8 workloads.

Stack

  1. This PR: db-config ConfigMap.
  2. internal/storage/dbconfig Go loader (feat(storage): add shared dbconfig loader #1302).
  3. Schema-version health check for both backends (feat(health): check the schema version of Spanner and PostgreSQL databases #1394).
  4. Storage factory: opens Spanner or PostgreSQL storage from dbconfig.Config (feat(storage): add a factory that opens the configured backend #1387).
  5. Explicit opt-in for the experimental PostgreSQL backend (feat(helm): require an explicit opt-in for the PostgreSQL backend #1388).
  6. Services move to the factory, one small PR each, each removing its old Spanner keys: xid_service, ESS, actuator, reconciler, log_monitor, rod_data_provider, dashboard_service.
  7. health_service: show db-config in the admin UI (feat(health): show db-config in the admin UI #1380), move health_service to the factory, then move the Spanner names into database.spanner.*.

PostgreSQL password delivery is outside this stack.

Assumptions & Edge Cases

  • The default render gains the db-config ConfigMap and one envFrom entry per deployment. Its Spanner values equal the per-service keys, and nothing reads them yet.
  • Deviation from the reachability rule: nothing reads db-config when this PR merges — keeping the stack in small PRs means its readers land later (the services through the storage factory, starting with xid_service, and the admin UI listing in feat(health): show db-config in the admin UI #1380) — if the stack stalls, main keeps an unused ConfigMap and its envFrom entries.
  • PostgreSQL defaults are only port: 5432 and sslMode: verify-full — any default host, user or database would name a server the chart doesn't deploy — if the server's CA isn't trusted, verify-full fails and the operator has to set sslMode. A CA can be delivered together with the password later.
  • No Cluster Toolkit change in this PR: db-config reads the Helm values the blueprint already sets (projectId, environment, experimentStateServer.spannerDatabaseName). xidService.spannerDatabaseName falls back to the chart default, which matches the xids-db-<env> database the blueprint creates. The blueprint runs log_monitor on Cloud Run by default, which db-config doesn't reach, so the PR that moves log_monitor to the factory also sets these variables in deploy/ctk_v2/modules/log_monitor/main.tf.
  • database.spanner.* comes in the last PR of the stack, so while services move one by one they all stay on the same databases.
  • backend: postgres renders the PostgreSQL keys here, so that this branch of the template is reviewed and tested. No service uses them yet, and feat(helm): require an explicit opt-in for the PostgreSQL backend #1388 puts postgres behind an explicit database.experimentalPostgres opt-in before any service moves to the factory.

Verification

  • bazel test for the //test/helm chart suites
  • helm lint deploy/helm
  • ./.githooks/pre-commit

TAG=agy
CONV=8498591f-f59d-4e82-a110-a2293d10543a

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for PostgreSQL configuration across multiple services by adding a shared dbconfig package, updating Helm charts to conditionally inject a db-config ConfigMap, and integrating these settings into the log monitor and health services. The feedback suggests optimizing the dbconfig package by removing redundant eager file reads of the password file during initialization, which will prevent unnecessary I/O and ensure file read errors are properly propagated rather than silently ignored.

Comment thread internal/storage/dbconfig/dbconfig.go Resolved
@andrzejfudro
andrzejfudro force-pushed the feat/shared-db-config branch from c6cede6 to 28c9a3b Compare October 19, 2026 08:41
@andrzejfudro andrzejfudro changed the title feat(storage): add shared dbconfig loader and Helm db-config ConfigMap feat(storage): add shared dbconfig loader and wire log_monitor Oct 19, 2026
@andrzejfudro
andrzejfudro added this pull request to stack #1303 October 19, 2026 08:53
@andrzejfudro
andrzejfudro force-pushed the feat/shared-db-config branch from 28c9a3b to 938e3b2 Compare October 19, 2026 12:48
@andrzejfudro andrzejfudro changed the title feat(storage): add shared dbconfig loader and wire log_monitor feat(helm): add shared db-config ConfigMap and health_service config discovery Oct 19, 2026
@andrzejfudro
andrzejfudro force-pushed the feat/shared-db-config branch from a48fc58 to 5b2f323 Compare October 22, 2026 09:19
Add a database block to values.yaml and render it into a db-config
ConfigMap that all 8 control-plane workloads load with envFrom. The
ConfigMap carries DB_BACKEND ("spanner" by default, or "postgres") plus
the selected backend's settings:

- spanner: SPANNER_ESS_DATABASE, SPANNER_XID_DATABASE and
  SPANNER_QUOTA_PROJECT_ID, taken from the values the per-service
  ConfigMaps already use, so both always agree;
- postgres: POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER,
  POSTGRES_ESS_DATABASE, POSTGRES_XID_DATABASE and POSTGRES_SSLMODE.

Any other backend fails the render. No service reads db-config yet;
services move to it one by one through the storage factory.

TAG=agy
CONV=8498591f-f59d-4e82-a110-a2293d10543a
Describe what the database values do instead of the migration plan,
and drop the admin UI reference, which only applies once db-config is
listed there.

TAG=agy
CONV=8498591f-f59d-4e82-a110-a2293d10543a
@andrzejfudro
andrzejfudro marked this pull request as ready for review October 22, 2026 14:38
Comment thread deploy/helm/values.yaml Resolved
Comment thread deploy/helm/templates/db-config.yaml Resolved
Comment thread deploy/helm/templates/db-config.yaml Resolved
Comment thread test/helm/db_config_test.py Resolved
Comment thread test/helm/db_config_test.py Resolved
Comment thread test/helm/db_config_test.py Resolved
Comment thread deploy/helm/templates/db-config.yaml Resolved
@VLukiantsev

Copy link
Copy Markdown
Collaborator

Thanks for the PR! Inline comments cover the main points (mostly the Postgres defaults). A few observations outside the diff:

  1. Stack not restacked on the current head: feat(helm): require an explicit opt-in for the PostgreSQL backend #1388's base still has older values.yaml comments and an older db_config_test.py than this PR's head. A gh stack rebase before review moves to the downstream PRs would help.
  2. Rollouts on db-config changes (non-blocking): changing db-config won't roll the pods. That matches the chart today (only components uses a checksum/config annotation), but it's worth deciding when the feat(storage): add shared dbconfig loader #1302 loader starts reading db-config.
  3. Docs (nit, can be deferred): deploy/helm/README.md doesn't document the new database: block. Fine to add once Postgres is actually selectable.

Address review feedback on the db-config ConfigMap:

- Add xmanager-cloud.essSpannerDatabase and xmanager-cloud.xidSpannerDatabase
  helpers and use them in db-config instead of an eighth copy of the
  fallback expressions.
- Assert that db-config matches the ESS and XID ConfigMaps under default
  values instead of pinning the values.yaml placeholders.
- Match the envFrom entry with an indentation-tolerant regex.

TAG=agy
CONV=8498591f-f59d-4e82-a110-a2293d10543a
Address review feedback: the PostgreSQL defaults pointed at a host the
chart does not deploy, used the superuser and disabled TLS.

- host, user, essDatabase and xidDatabase are now empty in values.yaml
  and required by the template when database.backend is postgres.
- Only the port (5432) and sslMode (verify-full) have defaults, so
  plaintext must be chosen explicitly.
- Tests cover the defaults and the render failure for each missing
  setting.

TAG=agy
CONV=8498591f-f59d-4e82-a110-a2293d10543a
@andrzejfudro

Copy link
Copy Markdown
Collaborator Author

Thanks! On the three points:

  1. Restack: we restack each PR onto its base right before it goes to review, so the PRs further up get the latest values.yaml and tests when their turn comes.
  2. Rollouts: agreed. Each PR that moves a service to the factory adds a checksum/db-config pod annotation, so a db-config change restarts the services that read it.
  3. Docs: I'll document the database: block in deploy/helm/README.md in the PR that makes PostgreSQL selectable.

@VLukiantsev VLukiantsev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — verified all review threads against 224d922 (Postgres settings now required with only port/verify-full defaults, Spanner helpers, contract-based tests); db_config_test passes locally. Thanks!

@andrzejfudro
andrzejfudro removed this pull request from stack #1390 October 23, 2026 09:13
@andrzejfudro
andrzejfudro added this pull request to stack #1395 October 23, 2026 09:16
@andrzejfudro
andrzejfudro added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit 47ecc2a Oct 23, 2026
19 checks passed
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.

2 participants