Merge pull request #107445 from mengjiao-liu/goroutine_leak_TestSelectorSpreadScore

Fix goroutine leaks in package `selectorspread`
This commit is contained in:
Kubernetes Prow Robot 2022-01-21 11:23:21 -08:00 committed by GitHub
commit 0c8074e1b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

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

View File

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