Add DocumentDB upgrade support with configurable PostgresImage and ImageVolume extensions#208
Conversation
433e80d to
1e6c870
Compare
1e6c870 to
ed68947
Compare
| nodeCount: ${{ inputs.node-count }} | ||
| instancesPerNode: ${{ inputs.instances-per-node }} | ||
| documentDBImage: ghcr.io/microsoft/documentdb/documentdb-local:16 | ||
| documentDBImage: ghcr.io/guanzhousongmicrosoft/documentdb-pg18-amd64:0.110.0 |
There was a problem hiding this comment.
See it's a draft. Just in case, we should not use any personal repo link.
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
ab04d57 to
1cc45ff
Compare
Signed-off-by: wenting <wentingwu@microsoft.com>
…stgres images Signed-off-by: wenting <wentingwu@microsoft.com>
1ae514c to
35b47ca
Compare
Signed-off-by: wenting <wentingwu@microsoft.com>
006724a to
a61d520
Compare
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
34f29f2 to
b2836ec
Compare
b9d97be to
5144126
Compare
Signed-off-by: wenting <wentingwu@microsoft.com>
5144126 to
d6db610
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces DocumentDB upgrade capabilities by adding support for configurable PostgreSQL and DocumentDB extension images, along with automated extension upgrade logic. The changes enable rolling upgrades of DocumentDB clusters with minimal downtime.
Changes:
- Adds
postgresImagefield to DocumentDB CRD spec for configurable Postgres base image selection - Adds
documentDBVersionfield to DocumentDB status to track the currently installed extension version - Implements automated extension upgrade logic that updates the extension image and runs
ALTER EXTENSIONwhen needed - Upgrades CNPG dependency from 0.26.1 to 0.27.0 to support ImageVolume-based extension loading
- Adds E2E upgrade tests that verify version transitions
- Removes DocumentDB image build from CI pipeline (now using external registry)
- Migrates certificate tests from testify to Ginkgo/Gomega for consistency
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| operator/src/api/preview/documentdb_types.go | Adds PostgresImage spec field and DocumentDBVersion status field to DocumentDB CRD |
| operator/src/config/crd/bases/documentdb.io_dbs.yaml | Updates CRD schema with new postgresImage and documentDBVersion fields |
| operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml | Mirrors CRD schema changes in Helm chart |
| operator/src/internal/cnpg/cnpg_cluster.go | Configures CNPG cluster with ImageVolume extensions and uses postgresImage from spec |
| operator/src/internal/controller/documentdb_controller.go | Adds upgrade logic with upgradeDocumentDBExtensionIfNeeded and updateExtensionImageIfNeeded functions, plus version parsing |
| operator/src/internal/controller/documentdb_controller_test.go | Comprehensive unit tests for upgrade logic using Ginkgo/Gomega |
| operator/src/internal/controller/certificate_controller_test.go | Extracts certificate tests into separate file, maintaining testify framework |
| operator/documentdb-helm-chart/Chart.yaml | Bumps CNPG dependency from 0.26.1 to 0.27.0 |
| .github/workflows/test-E2E.yml | Adds upgrade test scenario that patches image and verifies version transition |
| .github/workflows/test-integration.yml | Updates to use hardcoded DocumentDB image instead of version parameter |
| .github/workflows/test-backup-and-restore.yml | Removes unused documentdb_version input parameter |
| .github/workflows/test-build-and-package.yml | Removes DocumentDB image build step (now using external images) |
| .github/actions/setup-test-environment/action.yml | Enables ImageVolume feature gate in kind cluster config, upgrades to kind v0.31.0 with K8s v1.35.0 |
13fad47 to
d6db610
Compare
- Return errors for status updates in upgradeDocumentDBExtensionIfNeeded to trigger requeue - Refetch documentdb resource before status updates to avoid race conditions - Fix typo: reque -> requeue - Add documentation for version parsing in E2E workflow Signed-off-by: wenting <wentingwu@microsoft.com>
| patch := []map[string]interface{}{ | ||
| { | ||
| "op": "replace", | ||
| "path": fmt.Sprintf("/spec/postgresql/extensions/%d/image/reference", extIndex), |
There was a problem hiding this comment.
The JSON patch path uses /spec/postgresql/extensions/... but should use /spec/postgres/extensions/... to match the CNPG Cluster API. The field name in CNPG's ClusterSpec is PostgresConfiguration, which would serialize to postgres in JSON, not postgresql.
| "path": fmt.Sprintf("/spec/postgresql/extensions/%d/image/reference", extIndex), | |
| "path": fmt.Sprintf("/spec/postgres/extensions/%d/image/reference", extIndex), |
Summary
This PR introduces DocumentDB upgrade capabilities by adding a configurable
PostgresImagefield to the DocumentDB CRD and enabling ImageVolume-based extension loading through CNPG.Key Changes
CRD Updates
postgresImagefield to DocumentDB spec for configurable postgres image selectiondocumentDBVersionstatus field to track the current versionCNPG Integration
LD_LIBRARY_PATHfor extension loadinginitdb: could not look up effective user ID 105: user does not existerrorsCI/CD Updates
ImageVolumefeature gate in kind cluster configurationTesting
documentdb_controller_test.go