Summary
Follow-up from review of #374. Several review questions about how and where default values are surfaced were left unanswered when the PR was approved. This issue consolidates them so the team can make a consistent, deliberate decision about defaults across the DocumentDBSpec API.
The common theme: some defaults live in the CRD schema (default:), some are applied in code at runtime, and some GUCs are hardcoded. We should decide on a consistent convention and document the rationale.
Open questions
1. Image defaults: only postgres has a CRD default
Raised in this review comment:
So, we have default image only for postgres but not for documentDB and gateway?
In the image stanza, only image.postgres has a CRD-level default: (ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie). image.documentDB and image.gateway have no schema default.
This is likely intentional — the documentDB/gateway images follow the separate database version track and are defaulted in code (internal/utils/constants.go, cnpg-plugins/sidecar-injector/.../config.go) rather than in the CRD schema. The action here is probably to document the rationale (and confirm the two version tracks are the reason), not necessarily to add CRD defaults.
2. Plugin names: fixed defaults not expressed as CRD defaults
Raised in this review comment:
We have a default value for this which will never change in ideal case. Do we want to include it like other default values?
spec.plugins.sidecarInjectorName / spec.plugins.walReplicaName have well-known default names that are applied in code but not declared as CRD default: values. Decide whether to surface these as schema defaults for consistency with image.postgres.
3. Replication GUCs hardcoded to 10
Raised in this review comment:
Should we expose these with default value 10?
In operator/src/internal/cnpg/cnpg_cluster.go (buildPostgresConfiguration), max_replication_slots and max_wal_senders are hardcoded:
params := map[string]string{
"cron.database_name": "postgres",
"max_replication_slots": "10",
"max_wal_senders": "10",
}
Decide whether to expose these as user-configurable GUCs with a default of 10.
Note: this overlaps with the PostgreSQL parameter tuning work in #307, which introduces spec.postgresParameters for user-overridable GUCs (with cron.database_name, max_replication_slots, max_wal_senders, max_prepared_transactions listed as protected and non-overridable). Any change here should be reconciled with that design.
Proposed outcome
References
Summary
Follow-up from review of #374. Several review questions about how and where default values are surfaced were left unanswered when the PR was approved. This issue consolidates them so the team can make a consistent, deliberate decision about defaults across the
DocumentDBSpecAPI.The common theme: some defaults live in the CRD schema (
default:), some are applied in code at runtime, and some GUCs are hardcoded. We should decide on a consistent convention and document the rationale.Open questions
1. Image defaults: only
postgreshas a CRD defaultRaised in this review comment:
In the
imagestanza, onlyimage.postgreshas a CRD-leveldefault:(ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie).image.documentDBandimage.gatewayhave no schema default.This is likely intentional — the documentDB/gateway images follow the separate database version track and are defaulted in code (
internal/utils/constants.go,cnpg-plugins/sidecar-injector/.../config.go) rather than in the CRD schema. The action here is probably to document the rationale (and confirm the two version tracks are the reason), not necessarily to add CRD defaults.2. Plugin names: fixed defaults not expressed as CRD defaults
Raised in this review comment:
spec.plugins.sidecarInjectorName/spec.plugins.walReplicaNamehave well-known default names that are applied in code but not declared as CRDdefault:values. Decide whether to surface these as schema defaults for consistency withimage.postgres.3. Replication GUCs hardcoded to
10Raised in this review comment:
In
operator/src/internal/cnpg/cnpg_cluster.go(buildPostgresConfiguration),max_replication_slotsandmax_wal_sendersare hardcoded:Decide whether to expose these as user-configurable GUCs with a default of
10.Proposed outcome
postgresParametersdesign from feat: add PostgreSQL parameter tuning with memory-aware defaults #307.References
operator/src/internal/cnpg/cnpg_cluster.go—buildPostgresConfiguration;operator/src/api/preview/documentdb_types.go(image,pluginsstanzas)