@@ -26,6 +26,7 @@ import (
2626 "github.com/pkg/errors"
2727 "github.com/sirupsen/logrus"
2828 "golang.org/x/net/context"
29+ "golang.org/x/sys/unix"
2930 runtime "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
3031
3132 sandboxstore "github.com/containerd/cri/pkg/store/sandbox"
@@ -94,7 +95,9 @@ func (c *criService) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandb
9495 return & runtime.StopPodSandboxResponse {}, nil
9596}
9697
97- // stopSandboxContainer kills and deletes sandbox container.
98+ // stopSandboxContainer kills the sandbox container.
99+ // `task.Delete` is not called here because it will be called when
100+ // the event monitor handles the `TaskExit` event.
98101func (c * criService ) stopSandboxContainer (ctx context.Context , sandbox sandboxstore.Sandbox ) error {
99102 container := sandbox .Container
100103 task , err := container .Task (ctx , nil )
@@ -105,10 +108,10 @@ func (c *criService) stopSandboxContainer(ctx context.Context, sandbox sandboxst
105108 return errors .Wrap (err , "failed to get sandbox container" )
106109 }
107110
108- // Delete the sandbox container from containerd .
109- _ , err = task .Delete (ctx , containerd .WithProcessKill )
111+ // Kill the sandbox container.
112+ err = task .Kill (ctx , unix . SIGKILL , containerd .WithKillAll )
110113 if err != nil && ! errdefs .IsNotFound (err ) {
111- return errors .Wrap (err , "failed to delete sandbox container" )
114+ return errors .Wrap (err , "failed to kill sandbox container" )
112115 }
113116
114117 return c .waitSandboxStop (ctx , sandbox , killContainerTimeout )
0 commit comments