Skip to content

Add DocumentDB upgrade support with configurable PostgresImage and ImageVolume extensions#208

Open
WentingWu666666 wants to merge 16 commits intodocumentdb:mainfrom
WentingWu666666:users/wentingwu/upgrade-documentdb
Open

Add DocumentDB upgrade support with configurable PostgresImage and ImageVolume extensions#208
WentingWu666666 wants to merge 16 commits intodocumentdb:mainfrom
WentingWu666666:users/wentingwu/upgrade-documentdb

Conversation

@WentingWu666666
Copy link
Collaborator

@WentingWu666666 WentingWu666666 commented Jan 13, 2026

Summary

This PR introduces DocumentDB upgrade capabilities by adding a configurable PostgresImage field to the DocumentDB CRD and enabling ImageVolume-based extension loading through CNPG.

Key Changes

CRD Updates

  • Added postgresImage field to DocumentDB spec for configurable postgres image selection
  • Added documentDBVersion status field to track the current version

CNPG Integration

  • Upgraded CNPG to support ImageVolume extensions
  • Configure LD_LIBRARY_PATH for extension loading
  • Removed hardcoded PostgresUID/GID (105/108) to allow standard postgres images to use their default UID/GID values and avoid initdb: could not look up effective user ID 105: user does not exist errors

CI/CD Updates

  • Upgraded kind to v0.31.0 with Kubernetes v1.35.0 for E2E tests
  • Enabled ImageVolume feature gate in kind cluster configuration
  • Added E2E tests for upgrade scenarios

Testing

  • Unit tests: Added/updated in documentdb_controller_test.go
  • E2E tests: New upgrade test workflow added

@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch from 433e80d to 1e6c870 Compare January 13, 2026 02:04
@WentingWu666666 WentingWu666666 marked this pull request as ready for review January 13, 2026 02:04
@WentingWu666666 WentingWu666666 marked this pull request as draft January 13, 2026 02:04
@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch from 1e6c870 to ed68947 Compare January 13, 2026 02:16
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

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>
@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch from ab04d57 to 1cc45ff Compare January 21, 2026 20:38
Signed-off-by: wenting <wentingwu@microsoft.com>
…stgres images

Signed-off-by: wenting <wentingwu@microsoft.com>
@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch from 1ae514c to 35b47ca Compare January 22, 2026 02:07
Signed-off-by: wenting <wentingwu@microsoft.com>
@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch from 006724a to a61d520 Compare January 22, 2026 14:29
Signed-off-by: wenting <wentingwu@microsoft.com>
Signed-off-by: wenting <wentingwu@microsoft.com>
@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch 5 times, most recently from 34f29f2 to b2836ec Compare January 29, 2026 02:45
@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch 2 times, most recently from b9d97be to 5144126 Compare January 29, 2026 03:12
Signed-off-by: wenting <wentingwu@microsoft.com>
@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch from 5144126 to d6db610 Compare January 29, 2026 15:20
@WentingWu666666 WentingWu666666 changed the title upgrade documentdb extension Add DocumentDB upgrade support with configurable PostgresImage and ImageVolume extensions Jan 29, 2026
@WentingWu666666 WentingWu666666 marked this pull request as ready for review January 29, 2026 17:21
Copilot AI review requested due to automatic review settings January 29, 2026 17:21
Copy link
Contributor

Copilot AI left a comment

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 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 postgresImage field to DocumentDB CRD spec for configurable Postgres base image selection
  • Adds documentDBVersion field to DocumentDB status to track the currently installed extension version
  • Implements automated extension upgrade logic that updates the extension image and runs ALTER EXTENSION when 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

@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/upgrade-documentdb branch from 13fad47 to d6db610 Compare January 29, 2026 17:47
- 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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

patch := []map[string]interface{}{
{
"op": "replace",
"path": fmt.Sprintf("/spec/postgresql/extensions/%d/image/reference", extIndex),
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"path": fmt.Sprintf("/spec/postgresql/extensions/%d/image/reference", extIndex),
"path": fmt.Sprintf("/spec/postgres/extensions/%d/image/reference", extIndex),

Copilot uses AI. Check for mistakes.
@WentingWu666666 WentingWu666666 self-assigned this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants