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 committed Dec 9, 2024
1 parent 95b5f49 commit ae2ec82
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 @@ -356,7 +356,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 diconnected and the object is deleted.

Check failure on line 364 in pkg/provider/azure_local_services.go

View workflow job for this annotation

GitHub Actions / Check for spelling errors

diconnected ==> disconnected
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 ae2ec82

Please sign in to comment.