Skip to content

fix(services): reconcile managed service spec changes with patch strategy#10190

Merged
mnencia merged 4 commits intomainfrom
dev/10132
Mar 12, 2026
Merged

fix(services): reconcile managed service spec changes with patch strategy#10190
mnencia merged 4 commits intomainfrom
dev/10132

Conversation

@armru
Copy link
Member

@armru armru commented Mar 6, 2026

Previously, the cluster and pooler service reconcilers only detected changes in selectors, labels, and annotations. Changes to other spec fields like loadBalancerSourceRanges were silently ignored when using the patch update strategy, requiring users to switch to the replace strategy (which causes downtime) to apply spec changes.

Now the reconcilers compare the full service spec while preserving Kubernetes-managed and defaulted fields like ClusterIP, NodePort, and traffic policies.

Closes #10132

@armru armru requested a review from a team as a code owner March 6, 2026 10:26
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 6, 2026
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.27 release-1.28 labels Mar 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@dosubot dosubot bot added the bug 🐛 Something isn't working label Mar 6, 2026
@armru
Copy link
Member Author

armru commented Mar 6, 2026

/test

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/22767021629

@jbattiato jbattiato force-pushed the dev/10132 branch 4 times, most recently from ff56810 to 48489e8 Compare March 10, 2026 08:28
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 10, 2026
@jbattiato jbattiato force-pushed the dev/10132 branch 2 times, most recently from 3304103 to 1b8a249 Compare March 10, 2026 15:12
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 10, 2026
armru added 3 commits March 12, 2026 09:06
…tegy

Previously, the service reconciler only detected changes in selectors,
labels, and annotations. Changes to other spec fields like
loadBalancerSourceRanges were silently ignored when using the patch
update strategy, requiring users to switch to the replace strategy
(which causes downtime) to apply spec changes.

Now the reconciler compares the full service spec while preserving
Kubernetes-managed fields (ClusterIP, ClusterIPs, IPFamilies,
IPFamilyPolicy, InternalTrafficPolicy, SessionAffinity,
ExternalTrafficPolicy, HealthCheckNodePort, NodePort, Protocol,
TargetPort) via a reusable PreserveKubernetesDefaults function in
pkg/servicespec.

Closes #10132

Signed-off-by: Armando Ruocco <[email protected]>
…tion

The Pooler service reconciler was overwriting the entire ServiceSpec
from the expected service without preserving Kubernetes-managed fields
(ClusterIP, SessionAffinity, IPFamilies, etc.), causing unnecessary
API updates on every reconciliation loop.

Use servicespec.PreserveKubernetesDefaults to copy Kubernetes-assigned
and Kubernetes-defaulted fields from the living service before
comparing specs.

Signed-off-by: Armando Ruocco <[email protected]>
Kubernetes defaults AllocateLoadBalancerNodePorts to true for
LoadBalancer services. Without preserving this field, every
reconciliation loop would trigger an unnecessary update for
LoadBalancer services.

Signed-off-by: Armando Ruocco <[email protected]>
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 12, 2026
@mnencia
Copy link
Member

mnencia commented Mar 12, 2026

/test

@github-actions
Copy link
Contributor

@mnencia, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/23011368014

Signed-off-by: Marco Nenciarini <[email protected]>
@mnencia
Copy link
Member

mnencia commented Mar 12, 2026

/ok-to-merge

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Mar 12, 2026
@mnencia mnencia merged commit c16f748 into main Mar 12, 2026
43 of 44 checks passed
@mnencia mnencia deleted the dev/10132 branch March 12, 2026 16:50
cnpg-bot pushed a commit that referenced this pull request Mar 12, 2026
…tegy (#10190)

Previously, the cluster and pooler service reconcilers only detected
changes in selectors, labels, and annotations. Changes to other spec
fields like loadBalancerSourceRanges were silently ignored when using
the patch update strategy, requiring users to switch to the replace
strategy (which causes downtime) to apply spec changes.

Now the reconcilers compare the full service spec while preserving
Kubernetes-managed and defaulted fields like ClusterIP, NodePort, and
traffic policies.

Closes #10132

Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Co-authored-by: Marco Nenciarini <[email protected]>
(cherry picked from commit c16f748)
cnpg-bot pushed a commit that referenced this pull request Mar 12, 2026
…tegy (#10190)

Previously, the cluster and pooler service reconcilers only detected
changes in selectors, labels, and annotations. Changes to other spec
fields like loadBalancerSourceRanges were silently ignored when using
the patch update strategy, requiring users to switch to the replace
strategy (which causes downtime) to apply spec changes.

Now the reconcilers compare the full service spec while preserving
Kubernetes-managed and defaulted fields like ClusterIP, NodePort, and
traffic policies.

Closes #10132

Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Co-authored-by: Marco Nenciarini <[email protected]>
(cherry picked from commit c16f748)
cnpg-bot pushed a commit that referenced this pull request Mar 12, 2026
…tegy (#10190)

Previously, the cluster and pooler service reconcilers only detected
changes in selectors, labels, and annotations. Changes to other spec
fields like loadBalancerSourceRanges were silently ignored when using
the patch update strategy, requiring users to switch to the replace
strategy (which causes downtime) to apply spec changes.

Now the reconcilers compare the full service spec while preserving
Kubernetes-managed and defaulted fields like ClusterIP, NodePort, and
traffic policies.

Closes #10132

Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Co-authored-by: Marco Nenciarini <[email protected]>
(cherry picked from commit c16f748)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases bug 🐛 Something isn't working lgtm This PR has been approved by a maintainer ok to merge 👌 This PR can be merged release-1.25 release-1.27 release-1.28 size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LoadBalancer managed additional service updates with patch not reconciliated

5 participants