Commit 037f556
fix(services): use JSON merge patch for managed service spec reconciliation (cloudnative-pg#10311)
Previously, the patch strategy reconciler compared service specs by
starting from the proposed spec and explicitly preserving a hard-coded
list of Kubernetes-managed fields. Any field missing from that list —
such as LoadBalancerClass set by a cloud provider — would be zeroed out,
causing API errors on immutable fields and silent spec corruption on
mutable ones.
Replace this deny-list approach by computing an RFC 7386 JSON Merge
Patch between the last-applied and proposed specs, then applying it
onto the living service. A last-applied spec annotation
(cnpg.io/lastAppliedSpec) tracks what was previously applied so that
intentional field removals produce null entries in the patch.
This naturally preserves any field the operator doesn't control —
including fields set by cloud providers, admission webhooks, or future
Kubernetes versions — without needing to enumerate them.
Closes cloudnative-pg#10132
Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
(cherry picked from commit e20d4d5)1 parent 901b435 commit 037f556
File tree
8 files changed
+841
-511
lines changed- internal/controller
- pkg
- servicespec
- utils
8 files changed
+841
-511
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
404 | 405 | | |
405 | 406 | | |
406 | 407 | | |
| |||
441 | 442 | | |
442 | 443 | | |
443 | 444 | | |
444 | | - | |
445 | | - | |
446 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
| |||
454 | 458 | | |
455 | 459 | | |
456 | 460 | | |
| 461 | + | |
| 462 | + | |
457 | 463 | | |
458 | 464 | | |
459 | 465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
202 | 203 | | |
203 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
204 | 210 | | |
205 | 211 | | |
206 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
153 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
160 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
| |||
This file was deleted.
0 commit comments