Skip to content

feat: allow using an existing Cloudnative PG operator - #379

Closed
AntonOfTheWoods wants to merge 1 commit into
documentdb:mainfrom
AntonOfTheWoods:cnpg
Closed

AntonOfTheWoods wants to merge 1 commit into
documentdb:mainfrom
AntonOfTheWoods:cnpg

Conversation

@AntonOfTheWoods

Copy link
Copy Markdown
Contributor
  • flag for cnpg chart install
  • use a template for cnpg namespace rather than hard-code
  • various other potential failure ignores

No change to default behaviour

- 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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the DocumentDB Helm chart more configurable for environments that already provide a CloudNativePG operator.

Changes:

  • Adds a cnpg values 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
Comment on lines +40 to +43
cnpg:
install: true
namespaceOverride: cnpg-system
webhookFailurePolicy: Fail

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.

good suggestion. Let's keep the old full form.

Comment on lines +40 to +43
cnpg:
install: true
namespaceOverride: cnpg-system
webhookFailurePolicy: Fail
Comment on lines 84 to 86
# 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).
@documentdb-triage-tool documentdb-triage-tool Bot added the enhancement New feature or request label May 18, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: enhancement
Project fields suggested: Component manifests · Priority P2 · Effort L · Status Needs Review
Confidence: 0.72 (mixed)

Reasoning

effort 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 @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

@hossain-rayhan

hossain-rayhan commented May 18, 2026 •

Copy link
Copy Markdown
Collaborator

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

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.

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

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.

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:

  1. The upstream CNPG chart already exposes its own webhook failure policies under cloudnative-pg.webhook.mutating.failurePolicy and cloudnative-pg.webhook.validating.failurePolicy. Users seeing cnpg.webhookFailurePolicy next to those will reasonably assume it's a third knob for CNPG when it isn't.
  2. 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

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.

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.

@WentingWu666666

WentingWu666666 commented May 18, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@AntonOfTheWoods

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants