Repository navigation
fix(chi): recreate Services only for immutable type or headless changes (#2165 follow-up) - #2185
alex-zaitsev wants to merge 5 commits into
Conversation
Signed-off-by: Viacheslav Maltsev <devmalcevv@gmail.com>
| errServiceHeadlessChanged = errors.New("service headless mode changed") | ||
| ) | ||
|
|
||
| func shouldRecreateService(err error) bool { |
There was a problem hiding this comment.
Other immutable fields used to be fixed by the old delete+create fallback, for example switching ipFamilies / ipFamilyPolicy to a different primary family. Those now return Invalid on every reconcile and the Service never converges. If that's intended, could we at least say so in the error/event? Something like "immutable field changed, delete the Service manually".
There was a problem hiding this comment.
Thanks, agreed that Invalid can also arise from immutable fields such as the primary IP family. I kept the conservative behavior (do not delete a working Service on an ambiguous Invalid), and added an actionable failure event/log that says to validate the desired spec and manually delete/reconcile the Service for an intentional immutable-field transition. I also added a regression test for primary ipFamilies changes. See 3254455 and 6363391. I would prefer to handle automatic replacement only for specifically recognized transitions, not reintroduce IsInvalid as a blanket delete condition.
| // Recreate is for the situations a recreate actually fixes, see shouldRecreateService. Any other | ||
| // error - a read that was Forbidden or spent its retry budget, an update that hit a Conflict or | ||
| // an admission webhook that is down - says nothing about whether the Service is healthy, so | ||
| // surface it and let the next pass re-read. Falling through would delete and create the Service, |
There was a problem hiding this comment.
"let the next pass re-read": I don't think there is a next pass here. Host and cluster callers only log the error or register it as failed, and the CR-level call runs from a defer that drops it. So a single Conflict leaves the Service stale until the CHI changes again. Maybe retry Get+Update once on Conflict?
There was a problem hiding this comment.
Agreed — the comment about the next pass was too optimistic. reconcileService() now retries once on Conflict: it fetches the live Service again, then updates using the refreshed resourceVersion. A repeated conflict or failed refresh returns an error without deleting the Service. Added tests for successful retry, bounded repeated conflict, and failed read. See 3254455 and 6363391. CI is running on the new head.
|
@alex-zaitsev should I close my PR then? thx for picking this up |
|
@devmalcevv Thanks! No need to close #2165 yet. #2185 now includes the additional review fixes and regression tests (CI is running). The two PRs contain overlapping changes, so only one should be merged. If we use #2185 as the replacement, #2165 can then be closed; alternatively, you can cherry-pick the follow-up commits into #2165 and we can close #2185. |
| if apiErrors.IsConflict(err) { | ||
| // A concurrent Service update may have changed resourceVersion. Re-read the | ||
| // live object and retry once. Do not delete it if the retry also conflicts. | ||
| latestService, getErr := w.c.getService(ctx, service) |
There was a problem hiding this comment.
Nit: the retry has no tests for the re-Get returning NotFound or a changed type. Worth one case each?
Summary
Follow-up implementation for #2165, addressing the last review comment: #2165 (comment)
This branch starts at #2165's head commit (
2687ab5296ac457ee730525bc092f3c12af3ea9a), retaining its author's commit, then adds:errServiceHeadlessChangedsentinel returned fromupdateService()whenspec.clusterIPswitches betweenNoneand a regular ClusterIP (including an empty desired IP).NotFound, a Service type transition, or a headless/ClusterIP transition.apiErrors.IsInvalid(err)from the recreation decision. Invalid desired configuration now leaves a working Service in place and surfaces the failure.Why a separate PR: The GitHub integration used for this fix could not push to the original contributor fork (403, despite
maintainer_can_modify=true). The changes are on this Altinity branch so the author can cherry-pick the two follow-up commits into #2165, or maintainers can choose this branch as an alternative. This is not intended for merging alongside #2165 as an independent duplicate.Validation
pkg/controller/chi/worker-service.goand the newpkg/controller/chi/worker-service_test.go.test_010012should run in CI; they have not been run locally.