mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Merge pull request #125190 from pohly/record-event-panic
client-go record: avoid panic when watch creation failed
This commit is contained in:
commit
ea0ab06b69
@ -395,7 +395,11 @@ func (e *eventBroadcasterImpl) StartStructuredLogging(verbosity klog.Level) watc
|
||||
func (e *eventBroadcasterImpl) StartEventWatcher(eventHandler func(*v1.Event)) watch.Interface {
|
||||
watcher, err := e.Watch()
|
||||
if err != nil {
|
||||
// This function traditionally returns no error even though it can fail.
|
||||
// Instead, it logs the error and returns an empty watch. The empty
|
||||
// watch ensures that callers don't crash when calling Stop.
|
||||
klog.FromContext(e.cancelationCtx).Error(err, "Unable start event watcher (will not retry!)")
|
||||
return watch.NewEmptyWatch()
|
||||
}
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash()
|
||||
|
Loading…
Reference in New Issue
Block a user