Skip to content

Commit 371cb38

Browse files
authored
Store: Handle panics in service deletion handler. (#14056)
1 parent 6917c48 commit 371cb38

File tree

1 file changed

+11
-1
lines changed
  • internal/ingress/controller/store

1 file changed

+11
-1
lines changed

internal/ingress/controller/store/store.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,17 @@ func New(
817817
DeleteFunc: func(obj interface{}) {
818818
svc, ok := obj.(*corev1.Service)
819819
if !ok {
820-
klog.Errorf("unexpected type: %T", obj)
820+
// If we reached here it means the service was deleted but its final state is unrecorded.
821+
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
822+
if !ok {
823+
klog.ErrorS(nil, "Error obtaining object from tombstone", "key", obj)
824+
return
825+
}
826+
svc, ok = tombstone.Obj.(*corev1.Service)
827+
if !ok {
828+
klog.Errorf("Tombstone contained object that is not a Service: %#v", obj)
829+
return
830+
}
821831
}
822832
if svc.Spec.Type == corev1.ServiceTypeExternalName {
823833
updateCh.In() <- Event{

0 commit comments

Comments
 (0)