Merge pull request #115423 from pohly/scheduler-perf-goroutine-leak

scheduler perf: goroutine leak
This commit is contained in:
Kubernetes Prow Robot 2023-02-01 04:51:06 -08:00 committed by GitHub
commit 36450ee422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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())