diff --git a/pkg/scheduler/framework/plugins/selectorspread/selector_spread_perf_test.go b/pkg/scheduler/framework/plugins/selectorspread/selector_spread_perf_test.go index 0b661624fbc..6c2c7a0962c 100644 --- a/pkg/scheduler/framework/plugins/selectorspread/selector_spread_perf_test.go +++ b/pkg/scheduler/framework/plugins/selectorspread/selector_spread_perf_test.go @@ -58,7 +58,8 @@ func BenchmarkTestSelectorSpreadPriority(b *testing.B) { client := fake.NewSimpleClientset( &v1.Service{Spec: v1.ServiceSpec{Selector: map[string]string{"foo": ""}}}, ) - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() informerFactory := informers.NewSharedInformerFactory(client, 0) _ = informerFactory.Core().V1().Services().Lister() informerFactory.Start(ctx.Done()) diff --git a/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go b/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go index 4d147476bc8..d293e0d783d 100644 --- a/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go +++ b/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go @@ -396,7 +396,8 @@ func TestSelectorSpreadScore(t *testing.T) { t.Run(test.name, func(t *testing.T) { nodes := makeNodeList(test.nodes) snapshot := cache.NewSnapshot(test.pods, nodes) - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() informerFactory, err := populateAndStartInformers(ctx, test.rcs, test.rss, test.services, test.sss) if err != nil { t.Errorf("error creating informerFactory: %+v", err) @@ -653,7 +654,8 @@ func TestZoneSelectorSpreadPriority(t *testing.T) { t.Run(test.name, func(t *testing.T) { nodes := makeLabeledNodeList(labeledNodes) snapshot := cache.NewSnapshot(test.pods, nodes) - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() informerFactory, err := populateAndStartInformers(ctx, test.rcs, test.rss, test.services, test.sss) if err != nil { t.Errorf("error creating informerFactory: %+v", err)