From 1c4ed398abc1b4d736396d3ead7f5592394eea1a Mon Sep 17 00:00:00 2001 From: jokemanfire Date: Thu, 16 Jan 2025 10:15:09 +0800 Subject: [PATCH] When use crictl rmp -a -f, Avoid excessive coroutines causing context timeout Increase the maximum number of co processes limit Signed-off-by: jokemanfire --- cmd/crictl/sandbox.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/crictl/sandbox.go b/cmd/crictl/sandbox.go index cdc87dbfb2..4a0591540a 100644 --- a/cmd/crictl/sandbox.go +++ b/cmd/crictl/sandbox.go @@ -166,8 +166,13 @@ var removePodCommand = &cli.Command{ } funcs := []func() error{} + // set max concurrency to 10, to avoid too many goroutines + maxConcurrency := 10 + sem := make(chan struct{}, maxConcurrency) for _, id := range ids { funcs = append(funcs, func() error { + sem <- struct{}{} + defer func() { <-sem }() resp, err := InterruptableRPC(nil, func(ctx context.Context) (*pb.PodSandboxStatusResponse, error) { return runtimeClient.PodSandboxStatus(ctx, id, false) }) @@ -191,6 +196,7 @@ var removePodCommand = &cli.Command{ return nil }) + } return errorUtils.AggregateGoroutines(funcs...)