Skip to content

fix: handle DeletedFinalStateUnknown tombstones in TypedInformer's DeleteFunc - #4879

Merged
zac-nixon merged 2 commits into
kubernetes-sigs:mainfrom
ginbear:fix/typed-informer-deleted-final-state-unknown
Aug 17, 2026
Merged

zac-nixon merged 2 commits into
kubernetes-sigs:mainfrom
ginbear:fix/typed-informer-deleted-final-state-unknown

Conversation

@ginbear

@ginbear ginbear commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

TypedInformer[T].DeleteFunc asserts the deleted object directly to T:

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.DeletedFinalStateUnknown tombstone instead of the real object (this is documented on cache.ResourceEventHandler itself). 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.

panic: interface conversion: interface {} is cache.DeletedFinalStateUnknown, not *k8s.PodInfo [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x7f6c78c2c635]

goroutine 232 [running]:
k8s.io/apimachinery/pkg/util/runtime.handleCrash({0x7f6c7ba73a58, 0x1db2739f9c20}, {0x7f6c7b508480, 0x1db2739f9b60}, {0x0, 0x0, 0x7f6c75e0397a?})
	/go/pkg/mod/k8s.io/apimachinery@v0.36.2/pkg/util/runtime/runtime.go:116 +0x1a9
panic({0x7f6c7b508480?, 0x1db2739f9b60?})
	/usr/local/go/src/runtime/panic.go:860 +0x13a
sigs.k8s.io/aws-load-balancer-controller/v3/pkg/k8s.(*TypedInformer[...]).Start.func3()
	/workspace/pkg/k8s/typed_informer.go:47 +0x65
k8s.io/client-go/tools/cache.ResourceEventHandlerDetailedFuncs.OnDelete(...)
	/go/pkg/mod/k8s.io/client-go@v0.36.2/tools/cache/controller.go:345
k8s.io/client-go/tools/cache.(*processorListener).run.func1(...)
	/go/pkg/mod/k8s.io/client-go@v0.36.2/tools/cache/shared_informer.go:1365 +0x35d

Since only the Pod informer for TargetGroupBinding readiness gates goes
through TypedInformer, this is currently the only affected watch.

What changed

  • Unwrap the tombstone before asserting to T.
  • If the object still doesn't match T after unwrapping, log via
    HandleErrorWithContext and skip instead of panicking.

Checklist

  • Added tests that cover your change
  • Added/modified documentation as required
  • Manually tested

…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.
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ginbear / name: tora (b2404e7)

@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @ginbear!

It looks like this is your first PR to kubernetes-sigs/aws-load-balancer-controller 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/aws-load-balancer-controller has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 14, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@kubernetes-prow kubernetes-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 14, 2026
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 14, 2026
@zac-nixon

Copy link
Copy Markdown
Collaborator

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-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.50%. Comparing base (057c70f) to head (b2404e7).
⚠️ Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
pkg/k8s/typed_informer.go 50.00% 5 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kubernetes-prow kubernetes-prow Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 17, 2026
@ginbear

ginbear commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

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.
@ginbear
ginbear force-pushed the fix/typed-informer-deleted-final-state-unknown branch from f4f3989 to eda0b64 Compare August 17, 2026 00:56
@kubernetes-prow kubernetes-prow Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 17, 2026
@zac-nixon

Copy link
Copy Markdown
Collaborator

Thanks!

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 17, 2026

@shraddhabang shraddhabang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:
  • OWNERS [shraddhabang,zac-nixon]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zac-nixon
zac-nixon merged commit ed2b707 into kubernetes-sigs:main Aug 17, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants