Repository navigation
fix: handle DeletedFinalStateUnknown tombstones in TypedInformer's DeleteFunc - #4879
Conversation
…leteFunc TypedInformer[T].DeleteFunc asserted the deleted object directly to T. When the informer misses a delete event (e.g. right after a watch reconnect) and only notices the deletion on the next relist, client-go delivers a cache.DeletedFinalStateUnknown tombstone instead of the real object. The bare type assertion panics on that tombstone, and because apimachinery's crash handler re-panics after logging, the panic crashes the whole controller process instead of staying isolated to the informer goroutine. Only the Pod informer used for TargetGroupBinding readiness gates (added in kubernetes-sigs#4678) goes through TypedInformer, so this is the only watch affected. Unwrap the tombstone before asserting, and log-and-skip instead of panicking if the object still doesn't match.
|
|
|
Welcome @ginbear! |
|
Hi @ginbear. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
|
Hey, thanks for the debugging here. I thought about this issue a bit, and I don't even think we need the delete events as those don't impact the target group binding, because we are watching endpoint[slice]s too. Would you mind making the delete function empty (e.g. {}). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4879 +/- ##
==========================================
+ Coverage 57.49% 57.50% +0.01%
==========================================
Files 396 396
Lines 31621 31685 +64
==========================================
+ Hits 18179 18222 +43
- Misses 12384 12404 +20
- Partials 1058 1059 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks a lot for taking the time to look into this and for the clear explanation — that makes much more sense than my original approach! Updated: DeleteFunc is now a no-op, and I removed the tombstone-unwrapping helper (and its test) since it's no longer needed. |
Per review feedback: the TargetGroupBinding controller also watches EndpointSlices, which already reflect a Pod's removal, so the Pod informer's Delete event doesn't need to reach the handler at all. Making DeleteFunc a no-op removes the panic-on-tombstone path entirely instead of just handling the tombstone case.
f4f3989 to
eda0b64
Compare
|
Thanks! |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ginbear, shraddhabang, zac-nixon 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 |
Description
TypedInformer[T].DeleteFuncasserts the deleted object directly toT:https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/v3.5.0/pkg/k8s/typed_informer.go#L46-L49
When the informer misses the real delete event — for example right after a watch reconnect — and only notices the object is gone on the next relist, client-go delivers a
cache.DeletedFinalStateUnknowntombstone instead of the real object (this is documented oncache.ResourceEventHandleritself). The bare type assertion panics on that tombstone. Because apimachinery's crash handler re-panics after logging ("Observed a panic"), this crashes the whole controller process instead of staying isolated to the informer goroutine.Since only the Pod informer for TargetGroupBinding readiness gates goes
through
TypedInformer, this is currently the only affected watch.What changed
T.Tafter unwrapping, log viaHandleErrorWithContextand skip instead of panicking.Checklist