Skip to content

fix: use DeletionHandlingMetaNamespaceKeyFunc in DeleteFunc for tombstone support#70

Merged
bdehamer merged 2 commits intobdehamer/refactor-controller-splitfrom
copilot/sub-pr-69
Mar 23, 2026
Merged

fix: use DeletionHandlingMetaNamespaceKeyFunc in DeleteFunc for tombstone support#70
bdehamer merged 2 commits intobdehamer/refactor-controller-splitfrom
copilot/sub-pr-69

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

DeleteFunc was calling cache.MetaNamespaceKeyFunc(obj) after tombstone extraction, but when obj is a cache.DeletedFinalStateUnknown, this call errors and the delete event is silently dropped — a common case when the informer misses a delete during a resync.

Change

Replace with cache.DeletionHandlingMetaNamespaceKeyFunc(obj), which unwraps tombstones internally before computing the key:

// Before
key, err := cache.MetaNamespaceKeyFunc(obj)

// After
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)

This ensures delete events are reliably enqueued regardless of whether obj is a live object or a tombstone.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copy link
Contributor Author

Copilot AI commented Mar 23, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 10.244.0.2
    • Triggering command: /usr/bin/kubelet /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --node-ip=172.18.0.2 --node-labels= --provider-id=kind://docker/kind/kind-control-plane --runtime-cgroups=/system.slice/containerd.service -p 362ed76be0fb8547ac103d984da01135dc3/2df1b4ebfb67ffaf232cdda5db341d7de613bdca38f0db51�� mpile rg/toolchain@v0./run/systemd/generator.late ortc�� oller/... stmain.go rg/toolchain@v0./tmp/pty1124488072/pty.sock -p github.com/githu/tmp/kubelet-detect-safe-umount1660551564 t rg/toolchain@v0.0.1-go1.25.4.lin{{json .}} (packet block)
  • 10.244.0.4
    • Triggering command: /usr/bin/kubelet /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --node-ip=172.18.0.2 --node-labels= --provider-id=kind://docker/kind/kind-control-plane --runtime-cgroups=/system.slice/containerd.service -p 362ed76be0fb8547ac103d984da01135dc3/2df1b4ebfb67ffaf232cdda5db341d7de613bdca38f0db51�� mpile rg/toolchain@v0./run/systemd/generator.late ortc�� oller/... stmain.go rg/toolchain@v0./tmp/pty1124488072/pty.sock -p github.com/githu/tmp/kubelet-detect-safe-umount1660551564 t rg/toolchain@v0.0.1-go1.25.4.lin{{json .}} (packet block)
  • 5559030534559597294.4248727371591342039
    • Triggering command: /coredns /coredns -conf /etc/coredns/Corefile 961923f91426355d-trimpath ker/�� 4c3ed0e3:interna-p t .cfg -c=4 -nolocalimports t pkg/mod/golang.o-I -uns�� -unreachable=fal-t t by/91d04b7a5ddd0-m go t.go t pkg/mod/golang.o-m (dns block)
  • 6270441476402540855.9136771553807258282
    • Triggering command: /coredns /coredns -conf /etc/coredns/Corefile pkg/mod/golang.org/toolchain@v0.--detach -uns�� -unreachable=false t pkg/mod/golang.org/toolchain@v0.0.1-go1.25.4.linux-amd64/pkg/tool/linux_amd64/vet -c=4 -nolocalimports t pkg/mod/golang.org/toolchain@v0./var/run/docker/runtime-runc/moby 6abc�� -bool t rs/rpc-pipefs-generator -errorsas -ifaceassert l/linux_amd64/vero,bind rs/rpc-pipefs-ge/run/containerd/io.containerd.runtime.v2.task/k8s.io/2d72ec21c84a46a28d30ba449feffefccc1e02d6dbb7305d5bf69db0e47be44a/rootfs/product_uuid (dns block)
  • 6901084433189853732.4502597976292703045
    • Triggering command: /coredns /coredns -conf /etc/coredns/Corefile l/linux_amd64/asm ker/�� os/signal t .cfg -I /tmp/go-build220-w oduct_uuid 464bc37fac710727-I -uns�� -unreachable=fal-t eb150b8272c5ead0filter eb150b8272c5ead0-m by/91d04b7a5ddd0chmod GOAMD64_v1 t pkg/mod/golang.o-m (dns block)
  • 8063012640336197325.7990332815844875937
    • Triggering command: /coredns /coredns -conf /etc/coredns/Corefile pkg/mod/golang.org/toolchain@v0.--log -uns�� -unreachable=false t pkg/mod/golang.org/toolchain@v0.--systemd-cgroup 1/csidriver.go c0888bfba1f23a8c362ed76be0fb8547ac103d984da01135dc3/86fa02eddd39e5f88309407c968e4282�� (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] [WIP] Refactor: Apply feedback on splitting controller.go into focused files fix: use DeletionHandlingMetaNamespaceKeyFunc in DeleteFunc for tombstone support Mar 23, 2026
Copilot AI requested a review from bdehamer March 23, 2026 22:57
@bdehamer bdehamer marked this pull request as ready for review March 23, 2026 22:58
@bdehamer bdehamer requested a review from a team as a code owner March 23, 2026 22:58
Copilot AI review requested due to automatic review settings March 23, 2026 22:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Kubernetes informer delete-event handling by ensuring keys are generated correctly even when the delete event arrives as a tombstone (cache.DeletedFinalStateUnknown), preventing delete events from being dropped during resync/missed-watch scenarios.

Changes:

  • Switch DeleteFunc key generation from cache.MetaNamespaceKeyFunc to cache.DeletionHandlingMetaNamespaceKeyFunc to properly handle tombstones.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bdehamer bdehamer merged commit 8130fd7 into bdehamer/refactor-controller-split Mar 23, 2026
8 checks passed
@bdehamer bdehamer deleted the copilot/sub-pr-69 branch March 23, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants