Skip to content

Commit 95c004c

Browse files
CopilotIceber
andcommitted
Handle cache.DeletedFinalStateUnknown in DeleteFunc
Co-authored-by: Iceber <13391143+Iceber@users.noreply.github.com>
1 parent 9ddbe65 commit 95c004c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cmd/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ func main() {
109109
AddFunc: func(obj interface{}) { gateChecker(obj.(*unstructured.Unstructured)) },
110110
UpdateFunc: func(_, obj interface{}) { gateChecker(obj.(*unstructured.Unstructured)) },
111111
DeleteFunc: func(obj interface{}) {
112-
o := obj.(*unstructured.Unstructured)
112+
if d, ok := obj.(cache.DeletedFinalStateUnknown); ok {
113+
obj = d.Obj
114+
}
115+
o, ok := obj.(*unstructured.Unstructured)
116+
if !ok {
117+
klog.Errorf("Unexpected object type: %T", obj)
118+
return
119+
}
113120
klog.Warningf("Gate resource deleted: %s/%s", o.GetNamespace(), o.GetName())
114121
},
115122
}); err != nil {

0 commit comments

Comments
 (0)