Repository navigation
feat: fall back to a combined PostgreSQL + DocumentDB image when ImageVolume is unavailable - #487
Conversation
…ume is unavailable Add an imageMode setting (auto | imageVolume | combined). In auto mode the operator inspects node container runtimes and probes the API server when a CNPG cluster is first created; when ImageVolume is not usable (e.g. containerd 1.7, or ImageVolume gate disabled) it renders the cluster with a combined documentdb-combined:18-<version> image instead of an extension image volume. The selected mode is persisted in the documentdb.io/image-mode annotation and reported via an ImageModeSelected event. - New Dockerfile_combined and build/release pipeline entries - Webhook only rejects when imageMode=imageVolume - Helm: imageMode, image.documentdbCombined.repository, nodes RBAC, kubeVersion >= 1.32 - Fix: wire an event recorder into the DocumentDB controller - Design doc: docs/designs/combined-image-fallback.md Co-authored-by: Copilot <[email protected]> Copilot-Session: a381594c-340d-4439-8e1f-0388d38a3c61 Signed-off-by: Rayhan Hossain <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Image-version inconsistencies can bypass rollback protection and deploy older binaries against newer schemas, while an unguarded Helm value can block upgrades of existing releases.
4 open issues
What changed in this PR
Adds a combined PostgreSQL + DocumentDB image fallback through the existing product-neutral reconciliation engine, allowing new clusters to run without ImageVolume while preserving existing clusters’ layouts.
Changes:
- Detects ImageVolume support, persists the selected mode, and exposes configuration through Helm.
- Adds combined-image rendering, status reporting, build and release pipelines, and controller event recording.
- Lowers the chart’s Kubernetes minimum to 1.32 and updates tests and compatibility documentation.
| File | Description |
|---|---|
operator/src/internal/webhook/imagevolume.go |
Limits ImageVolume admission checks to forced mode. |
operator/src/internal/webhook/imagevolume_test.go |
Tests admission behavior for each mode. |
operator/src/internal/webhook/documentdb_webhook_test.go |
Tests default acceptance and forced rejection. |
operator/src/internal/utils/util.go |
Resolves combined-image references and tags. |
operator/src/internal/utils/image_source_test.go |
Tests combined-image version and repository selection. |
operator/src/internal/utils/constants.go |
Defines combined-image configuration constants. |
operator/src/internal/product/intent.go |
Adds the combined image to cluster intent. |
operator/src/internal/product/documentdb.go |
Supplies DocumentDB’s combined-image reference. |
operator/src/internal/product/documentdb_test.go |
Tests adapter image resolution. |
operator/src/internal/imagemode/suite_test.go |
Registers the image-mode test suite. |
operator/src/internal/imagemode/probe.go |
Adds the differential API capability probe. |
operator/src/internal/imagemode/imagemode.go |
Implements runtime checks and mode selection. |
operator/src/internal/imagemode/imagemode_test.go |
Tests detection and configuration behavior. |
operator/src/internal/engine/image_mode_test.go |
Tests initial mode selection and error handling. |
operator/src/internal/engine/extension.go |
Reports the combined image in status. |
operator/src/internal/engine/cluster_reconciler.go |
Selects and preserves cluster image mode. |
operator/src/internal/controller/documentdb_controller.go |
Wires detection and declares node-read permissions. |
operator/src/internal/controller/documentdb_controller_test.go |
Tests combined-image status reporting. |
operator/src/internal/cnpg/image_mode.go |
Applies and identifies combined-image rendering. |
operator/src/internal/cnpg/image_mode_test.go |
Tests rendering and image upgrade synchronization. |
operator/src/cmd/main.go |
Enables DocumentDB controller events. |
operator/documentdb-helm-chart/values.yaml |
Adds mode and combined-repository settings. |
operator/documentdb-helm-chart/tests/09_operator_deployment_test.yaml |
Tests environment wiring and mode validation. |
operator/documentdb-helm-chart/tests/05_clusterrole_test.yaml |
Tests node-read permissions. |
operator/documentdb-helm-chart/templates/09_documentdb_operator.yaml |
Passes image settings to the operator. |
operator/documentdb-helm-chart/templates/05_clusterrole.yaml |
Grants node-read permissions. |
operator/documentdb-helm-chart/Chart.yaml |
Lowers the Kubernetes floor to 1.32. |
docs/operator-public-documentation/preview/getting-started/before-you-start.md |
Updates prerequisites and fallback configuration. |
docs/operator-public-documentation/preview/faq.md |
Explains revised compatibility and fallback behavior. |
docs/designs/image-management.md |
Adds the combined image to the database track. |
docs/designs/combined-image-fallback.md |
Documents detection, persistence, upgrades, and limitations. |
CHANGELOG.md |
Records fallback support and event-recorder wiring. |
.github/workflows/test-e2e.yml |
Asserts ImageVolume selection and forces rejection mode. |
.github/workflows/release_documentdb_images.yml |
Promotes combined-image release tags. |
.github/workflows/build_documentdb_images.yml |
Builds, signs, and verifies combined images. |
.github/dockerfiles/Dockerfile_combined |
Packages PostgreSQL and DocumentDB together. |
Review effort: Balanced
| - name: DOCUMENTDB_EXTENSION_IMAGE_REPO | ||
| value: "{{ include "documentdb.imageRef" (dict "name" "image.documentdb.repository" "registry" .Values.image.registry "repo" .Values.image.documentdb.repository "tag" "") }}" | ||
| {{- end }} | ||
| {{- if .Values.image.documentdbCombined.repository }} |
There was a problem hiding this comment.
Independently reproduced against an installed pre-change release with helm upgrade documentdb-operator . -n documentdb-operator --reuse-values --dry-run=client: rendering fails at line 124 with nil pointer evaluating interface {}.repository. All 113 normal Helm tests pass, so an upgrade/reused-values regression case is needed in addition to guarding this new parent map. No cluster resources were changed by the dry-run.
| version := ImageTag(explicitExtensionImage) | ||
| if !combinedVersionTagPattern.MatchString(version) { | ||
| version = specVersion |
There was a problem hiding this comment.
Confirmed with a focused regression test on c532370. With combined mode configured, old schema/status 1.0.0, spec.documentDBVersion retained at 1.0.0, and a new explicit extension reference tagged 0.117.0 plus a SHA-256 digest, DocumentDBAdapter.CombinedImage renders documentdb-combined:18-0.117.0 while resolveBinaryVersion returns 1.0.0; validateImageRollback returns zero errors. This is a real rollback-guard bypass, not only inconsistent reporting. Please share effective binary-version resolution between rendering and admission, including tag+digest and fallback inputs.
| if currentExtImage == "" && cnpg.IsCombinedImageMode(cluster) { | ||
| currentExtImage = cluster.Spec.ImageName |
| returned, err := dryRunProbePod(ctx, c, namespace, imageProbeVolume()) | ||
| if err != nil { | ||
| logger.Info("ImageVolume API probe: image-volume probe pod rejected while baseline passed; feature unavailable", "error", err) | ||
| return ProbeUnsupported |
There was a problem hiding this comment.
Confirmed with focused tests injecting Kubernetes NewTimeoutError into each dry-run request independently. With a capable containerd 2.1.3 node and Kubernetes 1.34, a baseline timeout returns combined with nil error via the version fallback; an image-probe timeout also returns combined with nil error and incorrectly reports the feature gate disabled. Both outcomes permanently select a mode instead of retrying. Node-list transient errors are covered, but transient errors from both probe requests need the same treatment.
xgerman
left a comment
There was a problem hiding this comment.
Reviewed c532370. The combined-image rendering and fixed per-cluster mode are a useful approach, but the four existing findings should be addressed before merging. I added independent reproduction evidence to the relevant inline threads rather than opening duplicate findings.
| Severity | Issue | Verification |
|---|---|---|
| High | Combined-image rendering and admission disagree on the effective binary version, allowing a downgrade below the installed schema. | A focused test with installed schema 1.0.0, spec.documentDBVersion 1.0.0, and explicit image 0.117.0 plus a digest rendered combined:18-0.117.0 while admission resolved 1.0.0 and returned no rollback errors. #487 (comment) |
| High | A normal upgrade with --reuse-values fails on the new missing image.documentdbCombined map. | Reproduced using a client dry-run against an installed pre-change release; template line 124 raises a nil-pointer error. #487 (comment) |
| Medium | Transient failures in either API dry-run can permanently select combined mode. | Injected Kubernetes timeout errors into baseline and image requests independently; both returned combined with nil error on a capable 1.34 setup instead of retrying. #487 (comment) |
| Medium | Long-haul upgrade completion compares an image tag prefixed with the PostgreSQL major against an unprefixed DocumentDB version. | Traced GetCurrentDocumentDBImageTag through upgrade precondition and polling: 18-1.0.0 never equals target 1.0.0, so completed upgrades time out and remain eligible. #487 (comment) |
The existing focused Go suites (imagemode, cnpg, engine, product, utils, webhook, controller) and all 113 Helm tests pass, but miss the reproduced regression cases. CI E2E jobs are still in progress at review time. I did not deploy this PR or build the combined image locally; the only cluster interaction was a non-mutating Helm upgrade dry-run. Temporary reproduction tests were removed and no source changes remain.
- Admission and combined-image rendering now share util.ReleaseVersionTag, which ignores the tag of digest-qualified references. Previously "repo:0.117.0@sha256:..." rendered documentdb-combined:18-0.117.0 while admission validated spec.documentDBVersion, bypassing the image-rollback guard. Regression tests assert both resolve the same version. - The ImageVolume API probe returns retryable failures of either dry-run (timeouts, throttling, 5xx, transport errors) as errors, so Detect requeues instead of permanently selecting combined mode. Only definitive 4xx rejections count as unsupported or inconclusive. - Helm: guard image.documentdbCombined so `helm upgrade --reuse-values` from a release without the new values renders; add a regression test. - Long-haul: GetCurrentDocumentDBImageTag strips the combined image's PostgreSQL major prefix (18-1.0.0 -> 1.0.0) so upgrade checks compare DocumentDB versions. Co-authored-by: Copilot <[email protected]> Copilot-Session: 6c85cd4b-f086-46f7-8823-7e63c33e4de7 Signed-off-by: Rayhan Hossain <[email protected]>
Follow-up from a pre-review pass on PR documentdb#487. - release_operator.yml: a verify-combined-image job anonymously inspects documentdb-combined:18-<documentDbVersion> before promoting operator images, so a release fails while the fallback image is missing or private. - Probe pods carry minimal CPU/memory requests and limits, so namespaces whose quota or policy requires limits no longer make the probe inconclusive (which selected combined permanently below 1.35). 401 is retried. - CheckNodes only checks schedulable Linux nodes that report a runtime; with no such node (scale-to-zero, cordoned upgrade) the API server decides alone. - Combined-image rendering uses ExtractSemver (moved to utils and shared with admission) to recognize a release tag, so tags like ":0.110" fall back to documentDBVersion exactly as admission does. - IsCombinedImageMode also recognizes a combined cluster whose annotation was removed, so CNPG syncing does not wedge. - Move the nodes RBAC marker to a package-level block so controller-gen emits it; remove the unused webhook probeImageVolume helper. - Docs: detection details, release gate, minimum combined version (1.0.0), unsupported downgrade, recreating clusters stuck on containerd 1.7, frozen base image, and that forced imageVolume mode cannot check node runtimes. Co-authored-by: Copilot <[email protected]> Copilot-Session: 6c85cd4b-f086-46f7-8823-7e63c33e4de7 Signed-off-by: Rayhan Hossain <[email protected]>
The long-haul lint job runs actionlint (with shellcheck) through reviewdog on the workflow files a PR changes. Touching release_operator.yml surfaced its existing SC2129 (error level) and SC2086/SC2035 findings and failed the gate. Quote expansions, group the step-summary redirects, use ./*glob for the chart lookup, and pass docker build args as an array. No behaviour change. Co-authored-by: Copilot <[email protected]> Copilot-Session: 6c85cd4b-f086-46f7-8823-7e63c33e4de7 Signed-off-by: Rayhan Hossain <[email protected]>
|
Could we add a CI E2E case with ImageVolume disabled and |
It's the first follow-up item I believe. Additionally, I verified in local kind cluater and uploaded the test metrics here. Once I publish the combined image, I will add the e2e test. |


Summary
Today the operator only works where Kubernetes ImageVolume is usable. That needs both an API server with the
ImageVolumefeature gate on (GA in 1.35, beta and off by default in 1.33/1.34) and a node runtime that supports image volumes (containerd ≥ 2.1 or CRI-O ≥ 1.33). On other clusters the webhook rejectsDocumentDBcreation. Clusters with containerd 1.7 are worse: the API server accepts image volumes, so creation passes the webhook and the pods then hang.This PR adds a combined-image fallback. When ImageVolume isn't usable, the operator runs PostgreSQL from one image that already contains the DocumentDB extension,
documentdb-combined:18-<version>. ImageVolume stays the preferred layout wherever it works.How it works
imageMode:auto(default): decide per new cluster.imageVolume: always use ImageVolume. The webhook rejects creation when it's unavailable, which is the previous behavior.combined: always use the combined image.automode. It runs once, when the CNPGClusteris first created:combined. Transient API errors make it retry instead of picking a mode.documentdb.io/image-modeannotation on the CNPGCluster. Clusters created by earlier operator versions have no annotation and keep the ImageVolume layout.ImageModeSelectedevent on theDocumentDBexplains which mode was chosen and why..github/dockerfiles/Dockerfile_combinedon the CNPGpostgresql:18-minimal-trixiebase, with the same pinnedpostgresql-18-documentdbpackage as the extension image. It runs as UID 26. The tag18-<version>follows the extension version, so engine upgrades in combined mode roll the image through CNPG's normalspec.imageNameupdate.engine.ClusterReconciler(refactoring: product neutral operator core #482) through an optionalImageModeDetectorhook. Only DocumentDB uses it.Changes
internal/imagemodepackage (runtime parsing, node check, API probe,Detector), andcnpg.ApplyCombinedImageMode/IsCombinedImageMode. The engine selects the mode before creating the cluster, keeps existing combined clusters combined, and reports the combined image instatus.documentDBImage. The webhook rejects only whenimageMode=imageVolume, with a hint to switch toautoorcombined.ImageModeSelected,PVsRetained,ExtensionRollbackandSchemaUpdateAvailable; before this fix they were silently dropped.imageMode(validated) andimage.documentdbCombined.repositoryget/listonnodesin the operator ClusterRolekubeVersionfloor lowered from>= 1.33.0-0to>= 1.32.0-0build_documentdb_images.ymlbuilds, signs and verifiesdocumentdb-combined:18-<candidate>from the same verified .deb.release_documentdb_images.ymlpromotes it to18-<version>.imagevolume-preflightasserts the ImageVolume layout was selected.imagevolume-blockforcesimageMode=imageVolumeso it still covers the rejection path.docs/designs/combined-image-fallback.md, plus updates to the FAQ, Before You Start, image-management and the CHANGELOG.Compatibility
DocumentDBcreation now succeeds in combined mode instead of being rejected. SetimageMode: imageVolumeto keep the old fail-fast behavior.spec.image.postgresand the change-stream images. Only the release tag ofspec.image.documentDBis used.Testing
Unit and Helm tests
make test: all operator packages pass, including the newimagemodepackage, the engine tests for mode selection, combined rendering and sync, and the webhook behavior per mode.helm unittest: 113/113 pass, including the new env-var wiring,imageModevalidation and thenodesRBAC rule.kubeVersion: the chart renders on 1.32 and is refused on 1.31.kind compatibility matrix
Each case ran on a fresh kind cluster with operator and sidecar images built locally from this branch. The combined image was built from
Dockerfile_combinedwith the official PGDGpostgresql-18-documentdb 1.0-0-1.pgdg13+1package, and the chart was installed with default values plusimageModewhere noted. Every case checked:Clusterand the reason in theImageModeSelectedeventpg_extensionversion1.0-0imageModeautoimageVolumeautoimageVolumeautocombinedautocombinedautocombinedautocombinedautocombinedimageVolumeautoorcombinedcombinedcombined¹ A kind node image with the containerd 1.7.24 binaries from
kindest/node:v1.32.0. No stock kind image pairs Kubernetes 1.33 or 1.35 with containerd 1.7.Cases 5 and 6 show the runtime check works independently of the API probe: even when the API server supports ImageVolume, an old containerd still gets combined mode.
e2e in combined mode (Kubernetes 1.32.0, containerd 1.7.24)
lifecycle: 3 passed, 2 skippedstatus: 3/3 passeddata: 26/26 passedAll 6 clusters created by the suites used combined mode, and the operator logged no errors or restarts. An earlier run on the pre-rebase branch also upgraded the database version in combined mode (0.117.0 → 1.0.0); the rolling update and
ALTER EXTENSIONworked and data was preserved.Release steps (after merge)
documentdb-combined:18-1.0.0isn't published yet. Until it is,automode on clusters without ImageVolume would hang pulling a missing image.version: 1.0.0andpackage_source: apt. This only creates new candidate tags.documentdb:1.0.0andgateway:1.0.0tags stay as they are:documentdb-combinedGHCR package is public, so an anonymous pull works.Later database releases promote the combined image automatically.
Known limitations / follow-ups
combinedfor the whole new cluster. Node affinity isn't considered.combinedtoimageVolume.internal/imagemodehas its own copy of the ImageVolume probe, separate frominternal/validation. Merging them is a follow-up.