Repository navigation
fix cached resource replication after leader election loss - #4552
nfarhadian wants to merge 1 commit into
Conversation
Signed-off-by: Naeem Farhadian <n.f.azizi@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @nfarhadian. 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 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. |
Summary
ClusterCachedResource replication stops after the shard loses the leader lease, and status stays
Ready.Global (cache) informers were run with
Run(ctx.Done())on the leader election context. On lease loss they stop but stay inCachePartialMetadataDDSIF, so on the next termForResourcereturns the stopped informer,AddEventHandlerfails with "stopped already" and nothing is replicated anymore. Same happens silently when the CRD is deleted and recreated: the local informer is stopped, the replication controller keeps it and nothing requeues the ClusterCachedResource.Changes:
Start, so they are not tied to leadershipStartand removes them on exit, and stops when one of its informers is stopped. The ClusterCachedResource is requeued and the controller is recreatedReplicationStartedand phase are now set on every reconcile from the controller state, instead of once when the controller is registeredNotes:
CachePartialMetadataDDSIFstill has no worker. Adding one would start metadata informers for every cache server CRD on every shard. The cost is that global informers run until the process exits; if a cache CRD is deleted its reflector keeps retrying.Initializingwhile replication isn't running, there is no better phase in the API today.AddGVRLifecycleHandlercan race withupdateInformers(pkg/informer/informer.go), and this PR adds one more listener that goes away on lease loss.Tested with unit tests and manually with
kcp start --feature-gates=CacheAPIs=true --enable-leader-election=true: lease taken away and back, CRD deleted and recreated, CRD absent for 45s and recreated. Replication resumes in each case and status goesInitializing/NotRunningwhile the CRD is gone.What Type of PR Is This?
/kind bug
Related Issue(s)
Fixes #4451
Release Notes