From d733195cfe97d282c8998d92fd4fdba543a3c0f9 Mon Sep 17 00:00:00 2001 From: kkh Date: Mon, 5 Jan 2026 16:18:27 +0900 Subject: [PATCH] Fix potential goroutine leak in operation_executor_test.go If the test times out in isOperationRunConcurrently, the receiver channel stops listening. The goroutine spawned in startOperationAndBlock then blocks forever on ch <- nil. This commit updates startOperationAndBlock to use a select statement. It now waits for either the send to complete or the quit channel to be closed (signaling test completion). This ensures the goroutine exits cleanly even if the receiver is gone. Signed-off-by: kkh --- .../operationexecutor/operation_executor_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/pluginmanager/operationexecutor/operation_executor_test.go b/pkg/kubelet/pluginmanager/operationexecutor/operation_executor_test.go index f9e62c66ddc..2987d927d4b 100644 --- a/pkg/kubelet/pluginmanager/operationexecutor/operation_executor_test.go +++ b/pkg/kubelet/pluginmanager/operationexecutor/operation_executor_test.go @@ -185,6 +185,9 @@ func setup(t *testing.T) (context.Context, chan interface{}, chan interface{}, O // This function starts by writing to ch and blocks on the quit channel // until it is closed by the currently running test func startOperationAndBlock(ch chan<- interface{}, quit <-chan interface{}) { - ch <- nil - <-quit + select { + case ch <- nil: + <-quit + case <-quit: + } }