Stop outdated and orphaned sync controllers #211
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.46) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 467 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.368
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #211"
general
weight: 0.35
neolit123
Summary
The sync manager records sync controllers by the UID and resourceVersion of their
PublishedResource. Any change to a PublishedResource therefore started a second controller next to
the existing one, and both kept reconciling the same objects (#182). The same applies when the
change is the one that should stop the controller: setting the
deletionTimestamporspec.synchronization.enabled: falseproduces a new resourceVersion, socleanupControllerlookedfor the new key and did not find the running controller. And since PublishedResources have no
finalizer, a deleted PublishedResource only shows up as NotFound in
Reconcile, which was ignored,so its controller was never stopped.
This change records controllers per PublishedResource name, together with the key they were
created for:
after a successful start it is recorded and the outdated one is stopped. If the start fails, the
outdated controller keeps running and the reconcile is retried with backoff.
cleanupControllerlooks up the controller by name, so disabling sync and setting thedeletionTimestampstop it.Reconcilestops the controller of the deleted PublishedResource.--published-resource-selectorstops itscontroller. The watch predicate lets an update through if the old or the new labels match, so
the relabelling is reconciled once, but
Reconciledid not check the selector itself.Assumptions and limits:
new one's start until it is pre-seeded and the old one is cancelled; after that only in-flight
reconciles of the old one can overlap with the new one. The issue suggests draining first; I
kept the change small. Happy to add a drain step if you prefer.
StartControllerreturned)is not detected here; that is #190, addressed by #201. Until #201 lands, such a failure of the
successor leaves the PublishedResource without a controller, because the outdated one has
already been cancelled (on
mainit would keep running).Design note: when the replacement controller fails to start (probe error, resource not bound yet,
create error, pre-seed error), the outdated controller keeps running until a successor has started.
This favours availability; the start-error path is covered by
TestFailedStartKeepsOutdatedController. For spec changes (newgeneration or schema) you may prefer stopping the outdated controller first; happy to change that.
Unit tests cover the replacement, a failed start of the successor, deletion (NotFound), the
deletionTimestampcase and a PublishedResource that no longer matches the selector. Tested withgo test -race ./...,make lintandmake test-e2e(kcp 0.32).Overlap with open PRs: #191 and #201 change the same map and functions in the sync manager. They do
not fix this issue, but the code conflicts; whichever lands first, I will rebase this PR onto it.
This PR already includes #191's behaviour (a controller is recorded only after a successful
start); if #191 lands first I will rebase onto its
startAndRecordhelper. Draining the old controller before the new one starts could be a follow-up on top of#201, which adds an exit signal for sync controllers.
What Type of PR Is This?
/kind bug
Related Issue(s)
Fixes #182
Release Notes
``
release-note
``Fix outdated sync controllers continuing to run after a PublishedResource is updated, disabled, deleted or no longer matches the PublishedResource selector.