diff --git a/pkg/runtime/containerd/client.go b/pkg/runtime/containerd/client.go index c8b28e111..391c21749 100644 --- a/pkg/runtime/containerd/client.go +++ b/pkg/runtime/containerd/client.go @@ -706,9 +706,15 @@ func (cc *ctdClient) StopContainer(container string, timeout *time.Duration) (er } // After sending the signal, start the timer to force-kill the task - timeoutC := make(chan error) + timeoutC := make(<-chan containerd.ExitStatus) timer := time.AfterFunc(*timeout, func() { - timeoutC <- task.Kill(cc.ctx, syscall.SIGQUIT) + timeoutC, err = task.Wait(cc.ctx) + if err != nil { + return + } + if err = task.Kill(cc.ctx, syscall.SIGQUIT); err != nil { + return + } }) // Wait for the task to stop or the timer to fire @@ -716,7 +722,7 @@ func (cc *ctdClient) StopContainer(container string, timeout *time.Duration) (er case exitStatus := <-waitC: timer.Stop() // Cancel the force-kill timer err = exitStatus.Error() // TODO: Handle exit code - case err = <-timeoutC: // The kill timer has fired + case <-timeoutC: // The kill timer has fired } // Delete the task