Skip to content

K8SPG-1045: make certManagementPolicy immutable - #1785

Merged
hors merged 6 commits into
mainfrom
K8SPG-1045-fix-2
Aug 31, 2026
Merged

K8SPG-1045: make certManagementPolicy immutable#1785
hors merged 6 commits into
mainfrom
K8SPG-1045-fix-2

Conversation

@pooknull

@pooknull pooknull commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

https://perconadev.atlassian.net/browse/K8SPG-1045

DESCRIPTION

Problem:
Reconcile stops with an error if user changes certManagementPolicy from auto to operatorProvidedOnly and vice versa.

Solution:
certManagementPolicy is not intended to be changed after creation. This PR makes the change immutable via crd.yaml validation rules.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PG version?
  • Does the change support oldest and newest supported Kubernetes version?

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 spec.tls.certManagementPolicy immutable for PostgresCluster/PerconaPGCluster CRDs via CEL x-kubernetes-validations, preventing updates that previously caused reconciliation errors.

Changes:

  • Add a kubebuilder XValidation rule (self == oldSelf) to enforce immutability of certManagementPolicy.
  • Add a validation test to ensure updates that change certManagementPolicy are rejected by the API server.
  • Regenerate CRD/bundle YAML artifacts to include the new validation rule.

Reviewed changes

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

Show a summary per file
File Description
pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_types.go Adds CEL immutability validation marker for tls.certManagementPolicy.
internal/testing/validation/postgrescluster_test.go Adds a test that verifies certManagementPolicy cannot transition between enum values.
deploy/cw-bundle.yaml Regenerated bundle to include x-kubernetes-validations for immutability.
deploy/crd.yaml Regenerated CRD manifest to include x-kubernetes-validations for immutability.
deploy/bundle.yaml Regenerated bundle to include x-kubernetes-validations for immutability.
config/crd/bases/upstream.pgv2.percona.com_postgresclusters.yaml Updates base CRD schema with the immutability rule.
config/crd/bases/pgv2.percona.com_perconapgclusters.yaml Updates base CRD schema with the immutability rule.
build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml Updates generated CRD schema with the immutability rule.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +140 to +146
for _, from := range policies {
for _, to := range policies {
if from == to {
continue
}

t.Run(fmt.Sprintf("%s-to-%s", from, to), func(t *testing.T) {
egegunes
egegunes previously approved these changes Aug 27, 2026
@egegunes egegunes added this to the v3.1.0 milestone Aug 27, 2026
egegunes
egegunes previously approved these changes Aug 28, 2026

@hors hors left a comment

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.

@pooknull please check migration-from-crunchy-backup-restore test

@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
backup-enable-disable passed 00:00:00
builtin-extensions passed 00:00:00
custom-extensions passed 00:00:00
cert-manager-tls passed 00:00:00
cert-management-policy passed 00:00:00
custom-envs passed 00:00:00
custom-tls passed 00:00:00
database-init-sql passed 00:00:00
demand-backup passed 00:00:00
demand-backup-offline-snapshot passed 00:00:00
dynamic-configuration passed 00:00:00
extra-volumes passed 00:00:00
finalizers passed 00:00:00
init-deploy passed 00:00:00
huge-pages passed 00:00:00
logical-replica passed 00:00:00
major-upgrade-14-to-15 passed 00:00:00
major-upgrade-15-to-16 passed 00:00:00
major-upgrade-16-to-17 passed 00:00:00
major-upgrade-17-to-18 passed 00:15:12
major-upgrade-18-to-19 passed 00:00:00
ldap passed 00:00:00
ldap-tls passed 00:00:00
logcollection passed 00:00:00
monitoring passed 00:00:00
operator-upgrade-cert-manager passed 00:00:00
operator-upgrade-extensions passed 00:00:00
one-pod passed 00:00:00
repo-host-autogrow passed 00:00:00
operator-self-healing passed 00:00:00
pgbouncer passed 00:00:00
pg-tde passed 00:00:00
pg-tde-wal-encrypt passed 00:00:00
pitr passed 00:00:00
scaling passed 00:00:00
scheduled-backup passed 00:00:00
self-healing passed 00:00:00
sidecars passed 00:00:00
standby-pgbackrest passed 00:00:00
standby-streaming passed 00:00:00
start-from-backup passed 00:00:00
start-from-volumes passed 00:00:00
tablespaces passed 00:00:00
telemetry-transfer passed 00:00:00
upgrade-consistency passed 00:00:00
upgrade-minor passed 00:00:00
users passed 00:00:00
migration-from-crunchy-standby passed 00:00:00
migration-from-crunchy-pv passed 00:00:00
migration-from-crunchy-backup-restore passed 00:00:00
Summary Value
Tests Run 50/50
Job Duration 00:36:00
Total Test Time 00:15:12

commit: 1db6b8e
image: perconalab/percona-postgresql-operator:PR-1785-1db6b8e84

@hors
hors self-requested a review August 31, 2026 19:22
@hors
hors merged commit 6bdc505 into main Aug 31, 2026
18 checks passed
@hors
hors deleted the K8SPG-1045-fix-2 branch August 31, 2026 19:22
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.

7 participants