From 0e05804cb000e1e059faebc2c03e6d43d3e6933c Mon Sep 17 00:00:00 2001 From: Patryk Diak Date: Wed, 14 Aug 2024 08:28:11 +0200 Subject: [PATCH] EndpointSlice mirror controller: handle tombstone deletion Signed-off-by: Patryk Diak --- .../endpointslice_mirror_controller.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/go-controller/pkg/clustermanager/endpointslicemirror/endpointslice_mirror_controller.go b/go-controller/pkg/clustermanager/endpointslicemirror/endpointslice_mirror_controller.go index 8c9a7bdfa0a..eeca6530aa3 100644 --- a/go-controller/pkg/clustermanager/endpointslicemirror/endpointslice_mirror_controller.go +++ b/go-controller/pkg/clustermanager/endpointslicemirror/endpointslice_mirror_controller.go @@ -90,8 +90,16 @@ func (c *Controller) getDefaultEndpointSliceKey(endpointSlice *v1.EndpointSlice) func (c *Controller) enqueueEndpointSlice(obj interface{}) { eps, ok := obj.(*v1.EndpointSlice) if !ok { - klog.Errorf("Enqueued non-endpointSlice object %+v, skipping", obj) - return + tombstone, ok := obj.(cache.DeletedFinalStateUnknown) + if !ok { + utilruntime.HandleError(fmt.Errorf("passed object is neither an EndpointSlice nor a DeletedFinalStateUnknown type: %#v", obj)) + return + } + eps, ok = tombstone.Obj.(*v1.EndpointSlice) + if !ok { + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a EndpointSlice: %#v", obj)) + return + } } if key := c.getDefaultEndpointSliceKey(eps); key != "" { c.queue.AddRateLimited(key)