Repository navigation
feat: allow using an existing Cloudnative PG operator - #379
AntonOfTheWoods wants to merge 1 commit into
Conversation
- flag for cnpg chart install - use a template for cnpg namespace rather than hard-code - various other potential failure ignores Signed-off-by: Anton Melser <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR makes the DocumentDB Helm chart more configurable for environments that already provide a CloudNativePG operator.
Changes:
- Adds a
cnpgvalues block with install, namespace, and webhook failure-policy settings. - Conditions the CloudNativePG dependency and namespace creation on
cnpg.install. - Templates CNPG plugin resource namespaces through a shared helper.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
operator/documentdb-helm-chart/values.yaml |
Adds the new cnpg configuration block. |
operator/documentdb-helm-chart/Chart.yaml |
Adds a dependency alias and install condition for CloudNativePG. |
operator/documentdb-helm-chart/templates/_helpers.tpl |
Adds a helper for resolving the CNPG namespace. |
operator/documentdb-helm-chart/templates/01_namespace.yaml |
Makes CNPG namespace creation conditional and templated. |
operator/documentdb-helm-chart/templates/02_documentdb_sidecar_injector.yaml |
Uses the CNPG namespace helper for sidecar injector resources. |
operator/documentdb-helm-chart/templates/03_documentdb_wal_replica.yaml |
Uses the CNPG namespace helper for WAL replica resources. |
operator/documentdb-helm-chart/templates/10_documentdb_webhook.yaml |
Makes the DocumentDB validating webhook failure policy configurable. |
| version: "0.28.1" | ||
| repository: "https://cloudnative-pg.github.io/charts/" No newline at end of file | ||
| repository: "https://cloudnative-pg.github.io/charts/" | ||
| alias: cnpg |
| cnpg: | ||
| install: true | ||
| namespaceOverride: cnpg-system | ||
| webhookFailurePolicy: Fail |
There was a problem hiding this comment.
good suggestion. Let's keep the old full form.
| cnpg: | ||
| install: true | ||
| namespaceOverride: cnpg-system | ||
| webhookFailurePolicy: Fail |
| # Fail-closed: reject requests when the webhook is unreachable. | ||
| # Safe because readiness/startup probes keep the pod out of the | ||
| # Service endpoints until the TLS cert is loaded (CNPG pattern). |
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningeffort from diff stats (29+19 LOC, 7 files); LLM: Adds a flag to optionally skip CNPG chart installation and templatizes the namespace, enabling reuse of an existing CloudNativePG operator without breaking default behavior. If a label is wrong, remove it manually and ping |
|
Thanks for the contribution. A good e2e test, playground/ proper documentation update with guideline would be a great addition to this PR. |
| version: "0.28.1" | ||
| repository: "https://cloudnative-pg.github.io/charts/" No newline at end of file | ||
| repository: "https://cloudnative-pg.github.io/charts/" | ||
| alias: cnpg |
There was a problem hiding this comment.
Concern with alias: cnpg: this is a silent breaking change — any user who has overridden cloudnative-pg.* values today will find their overrides become no-ops after upgrading, since the subchart now reads from cnpg.* instead.
The benefit also feels small: it just shortens the key name. We can get the same BYO toggle without the rename by pointing condition: at a value under the existing cloudnative-pg: block. That keeps the chart backward compatible.
| cnpg: | ||
| install: true | ||
| namespaceOverride: cnpg-system | ||
| webhookFailurePolicy: Fail |
There was a problem hiding this comment.
webhookFailurePolicy controls the DocumentDB operator's webhook, not CNPG's — worth moving it out from under the CNPG block.
This value is consumed in 10_documentdb_webhook.yaml, which is the ValidatingWebhookConfiguration for dbs.documentdb.io — the DocumentDB operator's own webhook. It has no relationship to CNPG.
Two reasons the current placement is confusing:
- The upstream CNPG chart already exposes its own webhook failure policies under
cloudnative-pg.webhook.mutating.failurePolicyandcloudnative-pg.webhook.validating.failurePolicy. Users seeingcnpg.webhookFailurePolicynext to those will reasonably assume it's a third knob for CNPG when it isn't. - Grouping by use case ("things I added for the BYO PR") rather than by what the value configures makes the values schema harder to reason about over time.
Suggestion: move it to a top-level webhook: block, mirroring the upstream CNPG schema so the convention is consistent:
webhook:
validating:
failurePolicy: Fail
# templates/10_documentdb_webhook.yaml
failurePolicy: {{ .Values.webhook.validating.failurePolicy | default "Fail" }}
| pullPolicy: Always | ||
| cloudnative-pg: | ||
| cnpg: | ||
| install: true |
There was a problem hiding this comment.
Naming nit: consider bundled over install.
install: true|false reads as an action, which is a bit awkward in the false direction — does it mean "don't install now", "uninstall", or "it's already installed"? The state being expressed is really "is CNPG bundled with this chart, or provided externally?", and naming the state directly reads more cleanly:
cloudnative-pg:
bundled: true # default: chart installs and manages CNPG
# false: assume CNPG is already installed (BYO)
Symmetric, names the ownership relationship directly, and unlikely to ever collide with a key the upstream CNPG chart might add. Non-blocking — install or enabled are also defensible — but bundled is worth considering since this is the first user-facing API for the BYO toggle and changing it later requires a deprecation cycle.
|
Non-blocking from my side, just flagging for a follow-up issue. Separate from the comments I've already left on this PR: once users can opt into BYO mode, we implicitly take on a version-compatibility surface we didn't have before. The operator will run against whatever CNPG version the user already has installed, which could be older or newer than what we test against. Today there's no declared supported range, no detection, and no enforcement so out-of-range combinations will fail in subtle ways (silent backup skips, replication issues) that look like operator bugs. I don't want to expand the scope of this PR happy to address that as a follow-up. Filed #380 to track the compatibility work (declared range, runtime detection, CI matrix) so it doesn't get lost. |
|
Thanks for your careful comments. Unfortunately, given the current state of the chart and the level of quality you are requiring, it's not something I am going to be able to commit to. Quite frankly, the chart does not, shall we say, represent what is broadly considered best practice. Like at all. It's really more like a bunch of resource files from an alpha test put into a templates directory than an actual helm chart. I think maybe someone with commit rights should ask claude to turn it into a proper chart (with e2e tests maybe). It could also probably do what this PR helps to do. |
No change to default behaviour