Files
client-go/tools/record
Patrick Ohly 2231ff5ae4 client-go events: support context.Background() as context
If, for whatever reason, the context was context.Background(), the additional
goroutine was started and then got stuck forever because
context.Background().Done() is a nil channel. Found when indirectly
instantiating a broadcaster with such a context:

    found unexpected goroutines:
    [Goroutine 9106 in state chan receive (nil chan), with k8s.io/kubernetes/vendor/k8s.io/client-go/tools/record.NewBroadcaster.func1 on top of the stack:
	goroutine 9106 [chan receive (nil chan)]:
	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/record.NewBroadcaster.func1()
		/home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/record/event.go:206 +0x2c
	created by k8s.io/kubernetes/vendor/k8s.io/client-go/tools/record.NewBroadcaster in goroutine 8957
		/home/prow/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/record/event.go:205 +0x1a5

This can be fixed by checking for a nil channel.

Another problem also gets addressed: if Shutdown was called without canceling
the context, the goroutine also didn't stop. Now it waits for the cancelation
context and thus terminates in both cases.

Kubernetes-commit: eed6e29a5b8cfaa20fbc426541d9c74105d430ee
2023-12-01 18:35:28 +01:00
..
2022-07-19 20:54:13 -04:00
2018-11-17 16:45:36 +11:00