From 8357eead06809344cbb592fd72e9b4a032417ee7 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Sun, 18 Dec 2022 18:33:46 +0000 Subject: [PATCH] e2e node tains stop controller with context Informers controllers must use the stop channel, and not cancel the context of the List/Watch. Change-Id: I42e4ae4bad4fe6ad0da6fe1b3990ebe56c8eabd9 --- test/e2e/node/taints.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/test/e2e/node/taints.go b/test/e2e/node/taints.go index 325e7c9f933..90964b068cc 100644 --- a/test/e2e/node/taints.go +++ b/test/e2e/node/taints.go @@ -122,7 +122,7 @@ func createPodForTaintsTest(hasToleration bool, tolerationSeconds int, podName, // Creates and starts a controller (informer) that watches updates on a pod in given namespace with given name. It puts a new // struct into observedDeletion channel for every deletion it sees. -func createTestController(ctx context.Context, cs clientset.Interface, observedDeletions chan string, stopCh chan struct{}, podLabel, ns string) { +func createTestController(ctx context.Context, cs clientset.Interface, observedDeletions chan string, podLabel, ns string) { _, controller := cache.NewInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { @@ -148,7 +148,7 @@ func createTestController(ctx context.Context, cs clientset.Interface, observedD }, ) framework.Logf("Starting informer...") - go controller.Run(stopCh) + go controller.Run(ctx.Done()) } const ( @@ -184,8 +184,7 @@ var _ = SIGDescribe("NoExecuteTaintManager Single Pod [Serial]", func() { podName := "taint-eviction-1" pod := createPodForTaintsTest(false, 0, podName, podName, ns) observedDeletions := make(chan string, 100) - stopCh := make(chan struct{}) - createTestController(ctx, cs, observedDeletions, stopCh, podName, ns) + createTestController(ctx, cs, observedDeletions, podName, ns) ginkgo.By("Starting pod...") nodeName, err := testutils.RunPodAndGetNodeName(ctx, cs, pod, 2*time.Minute) @@ -216,8 +215,7 @@ var _ = SIGDescribe("NoExecuteTaintManager Single Pod [Serial]", func() { podName := "taint-eviction-2" pod := createPodForTaintsTest(true, 0, podName, podName, ns) observedDeletions := make(chan string, 100) - stopCh := make(chan struct{}) - createTestController(ctx, cs, observedDeletions, stopCh, podName, ns) + createTestController(ctx, cs, observedDeletions, podName, ns) ginkgo.By("Starting pod...") nodeName, err := testutils.RunPodAndGetNodeName(ctx, cs, pod, 2*time.Minute) @@ -249,8 +247,7 @@ var _ = SIGDescribe("NoExecuteTaintManager Single Pod [Serial]", func() { podName := "taint-eviction-3" pod := createPodForTaintsTest(true, kubeletPodDeletionDelaySeconds+2*additionalWaitPerDeleteSeconds, podName, podName, ns) observedDeletions := make(chan string, 100) - stopCh := make(chan struct{}) - createTestController(ctx, cs, observedDeletions, stopCh, podName, ns) + createTestController(ctx, cs, observedDeletions, podName, ns) ginkgo.By("Starting pod...") nodeName, err := testutils.RunPodAndGetNodeName(ctx, cs, pod, 2*time.Minute) @@ -294,8 +291,7 @@ var _ = SIGDescribe("NoExecuteTaintManager Single Pod [Serial]", func() { podName := "taint-eviction-4" pod := createPodForTaintsTest(true, 2*additionalWaitPerDeleteSeconds, podName, podName, ns) observedDeletions := make(chan string, 100) - stopCh := make(chan struct{}) - createTestController(ctx, cs, observedDeletions, stopCh, podName, ns) + createTestController(ctx, cs, observedDeletions, podName, ns) // 1. Run a pod with short toleration ginkgo.By("Starting pod...") @@ -396,8 +392,7 @@ var _ = SIGDescribe("NoExecuteTaintManager Multiple Pods [Serial]", func() { ginkgo.It("only evicts pods without tolerations from tainted nodes", func(ctx context.Context) { podGroup := "taint-eviction-a" observedDeletions := make(chan string, 100) - stopCh := make(chan struct{}) - createTestController(ctx, cs, observedDeletions, stopCh, podGroup, ns) + createTestController(ctx, cs, observedDeletions, podGroup, ns) pod1 := createPodForTaintsTest(false, 0, podGroup+"1", podGroup, ns) pod2 := createPodForTaintsTest(true, 0, podGroup+"2", podGroup, ns) @@ -455,8 +450,7 @@ var _ = SIGDescribe("NoExecuteTaintManager Multiple Pods [Serial]", func() { framework.ConformanceIt("evicts pods with minTolerationSeconds [Disruptive]", func(ctx context.Context) { podGroup := "taint-eviction-b" observedDeletions := make(chan string, 100) - stopCh := make(chan struct{}) - createTestController(ctx, cs, observedDeletions, stopCh, podGroup, ns) + createTestController(ctx, cs, observedDeletions, podGroup, ns) // 1. Run two pods both with toleration; one with tolerationSeconds=5, the other with 25 pod1 := createPodForTaintsTest(true, additionalWaitPerDeleteSeconds, podGroup+"1", podGroup, ns)