From f69371b1f69100ea304250bc30736baf3e934031 Mon Sep 17 00:00:00 2001 From: guodong Date: Sun, 13 Nov 2022 13:13:41 +0800 Subject: [PATCH] handle DeletedFinalStateUnknown in deleteGateway --- pkg/k8s/engine_controller.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/k8s/engine_controller.go b/pkg/k8s/engine_controller.go index 5dac50b..1e91d9d 100644 --- a/pkg/k8s/engine_controller.go +++ b/pkg/k8s/engine_controller.go @@ -303,7 +303,19 @@ func (c *EngineController) updateGateway(oldObj interface{}, newObj interface{}) } func (c *EngineController) deleteGateway(obj interface{}) { - gw := obj.(*v1alpha1.Gateway) + gw, ok := obj.(*v1alpha1.Gateway) + if !ok { + tombstone, ok := obj.(cache.DeletedFinalStateUnknown) + if !ok { + klog.Errorf("couldn't get object from tombstone %#v", obj) + return + } + gw, ok = tombstone.Obj.(*v1alpha1.Gateway) + if !ok { + klog.Errorf("tombstone contained object that is not a Gateway %#v", obj) + return + } + } klog.InfoS("deleting gateway", "gateway", klog.KObj(gw)) c.enqueue(gw) }