Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent panic when informer receives cache.DeletedFinalStateUnknown #7776

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
Loading