K8SPG-1045: make certManagementPolicy immutable - #1785
Merged
Conversation
pooknull
requested review from
egegunes,
gkech,
hors,
mayankshah1607,
nmarukovich and
oksana-grishchenko
as code owners
August 26, 2026 09:51
Contributor
There was a problem hiding this comment.
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
XValidationrule (self == oldSelf) to enforce immutability ofcertManagementPolicy. - Add a validation test to ensure updates that change
certManagementPolicyare 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
previously approved these changes
Aug 27, 2026
This reverts commit 08c2ee1.
egegunes
previously approved these changes
Aug 28, 2026
pooknull
requested review from
DhruthiKV,
eleo007,
jvpasinatto and
valmiranogueira
as code owners
August 31, 2026 08:35
gkech
approved these changes
Aug 31, 2026
egegunes
approved these changes
Aug 31, 2026
Collaborator
commit: 1db6b8e |
hors
self-requested a review
August 31, 2026 19:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://perconadev.atlassian.net/browse/K8SPG-1045
DESCRIPTION
Problem:
Reconcile stops with an error if user changes
certManagementPolicyfromautotooperatorProvidedOnlyand vice versa.Solution:
certManagementPolicyis not intended to be changed after creation. This PR makes the change immutable viacrd.yamlvalidation rules.CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability