Repository navigation
feat(helm): add shared db-config ConfigMap - #1293
Conversation
There was a problem hiding this comment.
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.
c6cede6 to
28c9a3b
Compare
28c9a3b to
938e3b2
Compare
a48fc58 to
5b2f323
Compare
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
5b2f323 to
3885120
Compare
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
|
Thanks for the PR! Inline comments cover the main points (mostly the Postgres defaults). A few observations outside the diff:
|
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
|
Thanks! On the three points:
|
VLukiantsev
left a comment
There was a problem hiding this comment.
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!
Summary
Adds the shared
db-configConfigMap: 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 readsdb-configyet.Key Changes
deploy/helm/values.yaml: adds adatabase:block withbackend("spanner"by default, or"postgres") andpostgres.*settings.host,user,essDatabaseandxidDatabaseare empty; onlyport(5432) andsslMode(verify-full) have defaults. There is no password field, becausedb-configis a plain ConfigMap.deploy/helm/templates/db-config.yaml: rendersDB_BACKENDplus 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.database.backendvalue fails the render.deploy/helm/templates/_helpers.tpl: addsxmanager-cloud.dbBackend, plusxmanager-cloud.essSpannerDatabase/xmanager-cloud.xidSpannerDatabasefor the Spanner database paths.actuator,dashboard-service,ess,health-service,log-monitor,reconciler,rodandxiddeployments loaddb-configwithenvFrom.test/helm/db_config_test.py): the default render matches the ESS and XID ConfigMaps. Also covered:envFromwiring of all 8 workloads.Stack
db-configConfigMap.internal/storage/dbconfigGo loader (feat(storage): add shared dbconfig loader #1302).dbconfig.Config(feat(storage): add a factory that opens the configured backend #1387).db-configin the admin UI (feat(health): show db-config in the admin UI #1380), move health_service to the factory, then move the Spanner names intodatabase.spanner.*.PostgreSQL password delivery is outside this stack.
Assumptions & Edge Cases
db-configConfigMap and oneenvFromentry per deployment. Its Spanner values equal the per-service keys, and nothing reads them yet.db-configwhen 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,mainkeeps an unused ConfigMap and itsenvFromentries.port: 5432andsslMode: 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-fullfails and the operator has to setsslMode. A CA can be delivered together with the password later.db-configreads the Helm values the blueprint already sets (projectId,environment,experimentStateServer.spannerDatabaseName).xidService.spannerDatabaseNamefalls back to the chart default, which matches thexids-db-<env>database the blueprint creates. The blueprint runs log_monitor on Cloud Run by default, whichdb-configdoesn't reach, so the PR that moves log_monitor to the factory also sets these variables indeploy/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: postgresrenders 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 putspostgresbehind an explicitdatabase.experimentalPostgresopt-in before any service moves to the factory.Verification
bazel testfor the//test/helmchart suiteshelm lint deploy/helm./.githooks/pre-commitTAG=agy
CONV=8498591f-f59d-4e82-a110-a2293d10543a