mirror of
https://github.com/kubernetes/client-go.git
synced 2026-01-16 23:16:12 +00:00
This changes the event recorder to use the equivalent of a select statement instead of a goroutine to record events. Previously, we used a goroutine to make event recording non-blocking. Unfortunately, this writes to a channel, and during shutdown we then race to write to a closed channel, panicing (caught by the error handler, but still) and making the race detector unhappy. Instead, we now use the select statement to make event emitting non-blocking, and if we'd block, we just drop the event. We already drop events if a particular sink is overloaded, so this just moves the incoming event queue to match that behavior (and makes the incoming event queue much longer). This means that, if the user uses `Eventf` and friends correctly (i.e. ensure they've returned by the time we call `Shutdown`), it's now safe to call Shutdown. This matches the conventional go guidance on channels: the writer should call close. Kubernetes-commit: e90e67bd002e70a525d3ee9045b213a5d826074d