From 116ada9a35bd6b1205a330d125e9fc7bf296fd88 Mon Sep 17 00:00:00 2001 From: Karthik Bhat Date: Wed, 3 Dec 2025 19:34:05 +0530 Subject: [PATCH] Fix TestTerminationOrderingSidecarStopAfterMain flake under stress --- .../kuberuntime/kuberuntime_termination_order_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/kuberuntime/kuberuntime_termination_order_test.go b/pkg/kubelet/kuberuntime/kuberuntime_termination_order_test.go index 67a93d8ac34..a183d6bcb25 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_termination_order_test.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_termination_order_test.go @@ -55,9 +55,11 @@ func TestTerminationOrderingSidecarStopAfterMain(t *testing.T) { var wg sync.WaitGroup wg.Add(1) - var sidecarWaitDelay int64 - var mainWaitDelay int64 + var sidecarWaitDelay, mainWaitDelay int64 + syncChannel := make(chan struct{}) + go func() { + close(syncChannel) // notifies other goroutine that this goroutine scheduled. sidecarWaitDelay = int64(to.waitForTurn("init", 30)) to.containerTerminated("init") wg.Done() @@ -65,6 +67,7 @@ func TestTerminationOrderingSidecarStopAfterMain(t *testing.T) { wg.Add(1) go func() { + <-syncChannel // make sure the other goroutine is scheduled. mainWaitDelay = int64(to.waitForTurn("main", 0)) time.Sleep(1 * time.Second) to.containerTerminated("main")