From a7f658e44245edf06c1a52a9a10e9b8fce5b9bd0 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 31 Jan 2023 11:58:16 +0100 Subject: [PATCH] test/integration: fix Broadcaster leak When starting a scheduler, the event broadcaster for it wasn't stopped. --- test/integration/util/util.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 46750857e7b..eb88c7d25dc 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -66,11 +66,16 @@ import ( type ShutdownFunc func() // StartScheduler configures and starts a scheduler given a handle to the clientSet interface -// and event broadcaster. It returns the running scheduler, podInformer and the shutdown function to stop it. +// and event broadcaster. It returns the running scheduler and podInformer. Background goroutines +// will keep running until the context is canceled. func StartScheduler(ctx context.Context, clientSet clientset.Interface, kubeConfig *restclient.Config, cfg *kubeschedulerconfig.KubeSchedulerConfiguration) (*scheduler.Scheduler, coreinformers.PodInformer) { informerFactory := scheduler.NewInformerFactory(clientSet, 0) evtBroadcaster := events.NewBroadcaster(&events.EventSinkImpl{ Interface: clientSet.EventsV1()}) + go func() { + <-ctx.Done() + evtBroadcaster.Shutdown() + }() evtBroadcaster.StartRecordingToSink(ctx.Done())