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
..
util simplify returning boolean expression in staging/src/k8s.io/client-go/tools 2021-05-24 07:15:36 +00:00
doc.go client-go/tools: Docs: Clarify what's "old" core/v1 and what's "new" events/v1beta1 2019-11-12 08:30:24 -05:00
event_test.go k8s.io/client-go/tools: support context for event recording 2023-09-18 09:13:22 +02:00
event.go client-go events: support context.Background() as context 2023-12-01 18:35:28 +01:00
events_cache_test.go generate ReportingInstance and ReportingController in Event 2023-03-27 22:23:45 +08:00
events_cache.go Generate and format files 2022-07-19 20:54:13 -04:00
fake.go k8s.io/client-go/tools: support context for event recording 2023-09-18 09:13:22 +02:00
main_test.go Cleanup math/rand package usage 2018-11-17 16:45:36 +11:00
OWNERS Check in OWNERS modified by update-yamlfmt.sh 2021-12-09 21:31:26 -05:00