Skip to content

Commit

Permalink
Prevent panic when informer receives cache.DeletedFinalStateUnknown (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelSpeed authored Jan 6, 2025
1 parent b69931d commit 9a7f730
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/provider/azure_local_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,23 @@ func (az *Cloud) setUpEndpointSlicesInformer(informerFactory informers.SharedInf
}
},
DeleteFunc: func(obj interface{}) {
es := obj.(*discovery_v1.EndpointSlice)
var es *discovery_v1.EndpointSlice
switch v := obj.(type) {
case *discovery_v1.EndpointSlice:
es = v
case cache.DeletedFinalStateUnknown:
// We may miss the deletion event if the watch stream is disconnected and the object is deleted.
var ok bool
es, ok = v.Obj.(*discovery_v1.EndpointSlice)
if !ok {
klog.Errorf("Cannot convert to *discovery_v1.EndpointSlice: %T", v.Obj)
return
}
default:
klog.Errorf("Cannot convert to *discovery_v1.EndpointSlice: %T", v)
return
}

az.endpointSlicesCache.Delete(strings.ToLower(fmt.Sprintf("%s/%s", es.Namespace, es.Name)))
},
})
Expand Down

0 comments on commit 9a7f730

Please sign in to comment.