Repository navigation
Do not fail cluster engagement because of a stopping sync controller - #215
Conversation
|
Hi @Wompipomp. Thanks for your PR. I'm waiting for a kcp-dev member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
/ok-to-test |
29cd467 to
5bcb6f3
Compare
|
@mjudeikis-bot review this. Do local extensive testing of this |
mjudeikis-bot
left a comment
There was a problem hiding this comment.
Verified: I built ./internal/... and ran go vet on the changed packages; both were clean. I ran go test -race on internal/kcp, internal/controllerutil and internal/controller/syncmanager, and all passed. A second run with -count=5 and no race detector also passed, so I saw no flakiness. Running the new TestEngageWhileControllerIsStopping on the parent commit b014641 fails with failed to watch for cluster "second": context canceled, and it passes at HEAD, so the test reproduces the bug this PR fixes. I also changed TestStoppedControllersDoNotLeak to use the plain cache instead of HandlerRemovingCache; it then fails (goroutines go from 17 to 57), so it really guards against the handler leak.
Behaviour: I checked the dependency code and found no problems. controller-runtime v0.24.1 starts Kind sources with the controller's own context, not the timed sync context (internal/controller/controller.go:371), and it passes that same context to GetInformer. So HandlerRemovingCache removes local handlers exactly when the controller stops. multicluster-runtime's Engage deduplicates by whether the old engagement context is still live, so giving each call its own engagement context does not cause duplicate watches. The engagement error is now swallowed only when the controller's own context is done; errors from running controllers still fail engagement, and TestEngageFailsForRunningController covers that. I ran everything without a real kcp or kube-apiserver because the sandbox has neither. Behaviour against live clusters (real informer RemoveEventHandler and an end-to-end PublishedResource change) is unverified; the e2e suite would cover it.
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: aedef84df12963de0605c5526cb54f29f7e411cd |
|
/retest |
5bcb6f3 to
012baed
Compare
|
@Wompipomp one more rebase please :D |
rebasing all day 😄 |
A sync controller whose context is cancelled (because it was stopped, or because it exited and is about to be restarted) stays registered with the DynamicMultiClusterManager until it is removed under the runnables lock. Forwarding an Engage() call to it fails, because its per-cluster watch cannot sync with a cancelled context. The cluster tracker then returns that error, and the cluster provider drops the whole cluster, so no sync controller serves it until the cluster is engaged again or the agent restarts. Ignore engagement errors of a controller that is stopping. This also applies to pre-seeding, so a controller that is stopped while it is being started no longer fails StartController. Errors of running controllers still abort the engagement. on-behalf-of: @eon-se opensource@eon.com Signed-off-by: Mark Altmann <mark.altmann.external@eon.com>
012baed to
0a6e446
Compare
Sorry :D I want to cut a release and make sure all your changes are in there :D |
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: a8299268ed98f896cc5811d1b78867b57cfdface |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mjudeikis The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: ba3a42aa6299604c41bc15df5f958790e4725045 |
|
Sorry I pushed ontop. Want to get this merged so we can tag a release :) |
no worries 😄 Thanks for merging. Yes of course will do 👍 |
Summary
A sync controller whose context is cancelled (it was stopped, or it exited and #201 is about to
restart it) is still registered with the
DynamicMultiClusterManageruntil it is removed under therunnables lock. Forwarding an
Engage()call to it can fail,because its per-cluster watch may not sync with a cancelled context. The cluster tracker returned that
error, and multicluster-runtime then removed the whole cluster, so no sync controller served it
until it was engaged again or the agent restarted.
Engagement errors of a controller that is stopping (its context is done) are now ignored. This also
covers pre-seeding, so a controller that is stopped while it starts no longer fails
StartController(it is then restarted through #201's backoff). Errors of running controllersstill abort the engagement as before (
TestEngageFailsForRunningController).This uses the controller's context that #212 stores next to each controller in the DMCM.
Tested with
go test -race ./...andmake lint(no new findings) after the rebase; e2e runs in CI.TestEngageWhileControllerIsStoppingkeeps astopped controller inside a reconcile, engages a new cluster in the meantime, and fails without the
fix with
failed to watch for cluster "second": context canceled.Rebased onto
mainafter #212 was merged.What Type of PR Is This?
/kind bug
Related Issue(s)
Fixes #214
Release Notes