From 29d6d03a3cf7433f5ad1ca81ba8dc986a6dc023c Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 19 Dec 2022 07:58:10 +0100 Subject: [PATCH 1/2] e2e scheduling: fix scope of context.WithTimeout The original intend from v1.26.0 was to only apply the timeout to the following cache.WaitForCacheSync. --- test/e2e/scheduling/limit_range.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/scheduling/limit_range.go b/test/e2e/scheduling/limit_range.go index 8cdf6f158a2..0bb77388cca 100644 --- a/test/e2e/scheduling/limit_range.go +++ b/test/e2e/scheduling/limit_range.go @@ -93,9 +93,9 @@ var _ = SIGDescribe("LimitRange", func() { _, informer, w, _ := watchtools.NewIndexerInformerWatcher(lw, &v1.LimitRange{}) defer w.Stop() - ctx, cancelCtx := context.WithTimeout(ctx, wait.ForeverTestTimeout) - defer cancelCtx() - if !cache.WaitForCacheSync(ctx.Done(), informer.HasSynced) { + timeoutCtx, cancel := context.WithTimeout(ctx, wait.ForeverTestTimeout) + defer cancel() + if !cache.WaitForCacheSync(timeoutCtx.Done(), informer.HasSynced) { framework.Failf("Timeout while waiting for LimitRange informer to sync") } From 1bc24630daebd0ad13fd3494029c215897f7ebf7 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 19 Dec 2022 08:19:16 +0100 Subject: [PATCH 2/2] e2e scheduling: remove redundant stopCh The ctx.Done() channel associated with the current test can be used instead. This is a simplification, both approaches work. --- test/e2e/scheduling/preemption.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/e2e/scheduling/preemption.go b/test/e2e/scheduling/preemption.go index bfb199fcc7c..05cec6912d4 100644 --- a/test/e2e/scheduling/preemption.go +++ b/test/e2e/scheduling/preemption.go @@ -623,7 +623,6 @@ var _ = SIGDescribe("SchedulerPreemption [Serial]", func() { */ framework.ConformanceIt("runs ReplicaSets to verify preemption running path", func(ctx context.Context) { podNamesSeen := []int32{0, 0, 0} - stopCh := make(chan struct{}) // create a pod controller to list/watch pod events from the test framework namespace _, podController := cache.NewInformer( @@ -652,8 +651,7 @@ var _ = SIGDescribe("SchedulerPreemption [Serial]", func() { }, }, ) - go podController.Run(stopCh) - defer close(stopCh) + go podController.Run(ctx.Done()) // prepare three ReplicaSet rsConfs := []pauseRSConfig{