Skip to content

Commit ec9e336

Browse files
authored
Merge pull request #708 from yuqitao/master
fix a bug in closure function
2 parents b76cca2 + 056969f commit ec9e336

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

cmd/crictl/sandbox.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,26 @@ var removePodCommand = &cli.Command{
155155

156156
funcs := []func() error{}
157157
for _, id := range ids {
158+
podId := id
158159
funcs = append(funcs, func() error {
159160
resp, err := runtimeClient.PodSandboxStatus(context.Background(),
160-
&pb.PodSandboxStatusRequest{PodSandboxId: id})
161+
&pb.PodSandboxStatusRequest{PodSandboxId: podId})
161162
if err != nil {
162-
return errors.Wrapf(err, "getting sandbox status of pod %q", id)
163+
return errors.Wrapf(err, "getting sandbox status of pod %q", podId)
163164
}
164165
if resp.Status.State == pb.PodSandboxState_SANDBOX_READY {
165166
if ctx.Bool("force") {
166-
if err := StopPodSandbox(runtimeClient, id); err != nil {
167-
return errors.Wrapf(err, "stopping the pod sandbox %q failed", id)
167+
if err := StopPodSandbox(runtimeClient, podId); err != nil {
168+
return errors.Wrapf(err, "stopping the pod sandbox %q failed", podId)
168169
}
169170
} else {
170-
return errors.Errorf("pod sandbox %q is running, please stop it first", id)
171+
return errors.Errorf("pod sandbox %q is running, please stop it first", podId)
171172
}
172173
}
173174

174-
err = RemovePodSandbox(runtimeClient, id)
175+
err = RemovePodSandbox(runtimeClient, podId)
175176
if err != nil {
176-
return errors.Wrapf(err, "removing the pod sandbox %q", id)
177+
return errors.Wrapf(err, "removing the pod sandbox %q", podId)
177178
}
178179

179180
return nil

0 commit comments

Comments
 (0)