mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
add comment describing the race condition + TODO for appropriate test
This commit is contained in:
parent
d8ee8e427e
commit
932f98acaf
@ -124,6 +124,18 @@ func (sw *StreamWatcher) receive() {
|
|||||||
klog.V(5).Infof("Unable to decode an event from the watch stream: %v", err)
|
klog.V(5).Infof("Unable to decode an event from the watch stream: %v", err)
|
||||||
} else {
|
} else {
|
||||||
select {
|
select {
|
||||||
|
// TODO: figure out how to test that sending the error after an externally stopped watcher
|
||||||
|
// cannot block anymore because of the introduced done channel.
|
||||||
|
// The function receive checks under a lock whether the watch has been stopped,
|
||||||
|
// before an error from the watch stream is reported to the result channel.
|
||||||
|
// The problem here is, that in between the watcher might be stopped by
|
||||||
|
// calling the Stop method. In the actual code this is done by the
|
||||||
|
// cache.Reflector using the streamwatcher by a defer (method watchHandler)
|
||||||
|
// which is executed after the caller already stopped reading from the result channel.
|
||||||
|
// As a result the stopping flag might be set after the check
|
||||||
|
// and trying to send the error event blocks this send operation forever,
|
||||||
|
// because there will never be a receiver again.
|
||||||
|
// This results in dead go routines trying to send on the result channel, forever.
|
||||||
case <-sw.done:
|
case <-sw.done:
|
||||||
return
|
return
|
||||||
case sw.result <- Event{
|
case sw.result <- Event{
|
||||||
|
Loading…
Reference in New Issue
Block a user