Skip to content

Commit

Permalink
Merge pull request #708 from yuqitao/master
Browse files Browse the repository at this point in the history
fix a bug in closure function
  • Loading branch information
k8s-ci-robot authored Dec 21, 2020
2 parents b76cca2 + 056969f commit ec9e336
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cmd/crictl/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,26 @@ var removePodCommand = &cli.Command{

funcs := []func() error{}
for _, id := range ids {
podId := id
funcs = append(funcs, func() error {
resp, err := runtimeClient.PodSandboxStatus(context.Background(),
&pb.PodSandboxStatusRequest{PodSandboxId: id})
&pb.PodSandboxStatusRequest{PodSandboxId: podId})
if err != nil {
return errors.Wrapf(err, "getting sandbox status of pod %q", id)
return errors.Wrapf(err, "getting sandbox status of pod %q", podId)
}
if resp.Status.State == pb.PodSandboxState_SANDBOX_READY {
if ctx.Bool("force") {
if err := StopPodSandbox(runtimeClient, id); err != nil {
return errors.Wrapf(err, "stopping the pod sandbox %q failed", id)
if err := StopPodSandbox(runtimeClient, podId); err != nil {
return errors.Wrapf(err, "stopping the pod sandbox %q failed", podId)
}
} else {
return errors.Errorf("pod sandbox %q is running, please stop it first", id)
return errors.Errorf("pod sandbox %q is running, please stop it first", podId)
}
}

err = RemovePodSandbox(runtimeClient, id)
err = RemovePodSandbox(runtimeClient, podId)
if err != nil {
return errors.Wrapf(err, "removing the pod sandbox %q", id)
return errors.Wrapf(err, "removing the pod sandbox %q", podId)
}

return nil
Expand Down

0 comments on commit ec9e336

Please sign in to comment.