Skip to content

Commit 1c4ed39

Browse files
committed
When use crictl rmp -a -f, Avoid excessive coroutines causing context timeout
Increase the maximum number of co processes limit Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
1 parent 26916d0 commit 1c4ed39

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/crictl/sandbox.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,13 @@ var removePodCommand = &cli.Command{
166166
}
167167

168168
funcs := []func() error{}
169+
// set max concurrency to 10, to avoid too many goroutines
170+
maxConcurrency := 10
171+
sem := make(chan struct{}, maxConcurrency)
169172
for _, id := range ids {
170173
funcs = append(funcs, func() error {
174+
sem <- struct{}{}
175+
defer func() { <-sem }()
171176
resp, err := InterruptableRPC(nil, func(ctx context.Context) (*pb.PodSandboxStatusResponse, error) {
172177
return runtimeClient.PodSandboxStatus(ctx, id, false)
173178
})
@@ -191,6 +196,7 @@ var removePodCommand = &cli.Command{
191196

192197
return nil
193198
})
199+
194200
}
195201

196202
return errorUtils.AggregateGoroutines(funcs...)

0 commit comments

Comments
 (0)