Skip to content

Commit

Permalink
When use crictl rmp -a -f, Avoid excessive coroutines causing context…
Browse files Browse the repository at this point in the history
… timeout

Increase the maximum number of co processes limit

Signed-off-by: jokemanfire <[email protected]>
  • Loading branch information
jokemanfire committed Jan 16, 2025
1 parent 26916d0 commit 1c4ed39
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/crictl/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -191,6 +196,7 @@ var removePodCommand = &cli.Command{

return nil
})

}

return errorUtils.AggregateGoroutines(funcs...)
Expand Down

0 comments on commit 1c4ed39

Please sign in to comment.