Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 0d535f5

Browse files
committed
shimv2: kill a container return directly once the container termianted
According to CRI specs, kubelet will call StopPodSandbox() at least once before calling RemovePodSandbox, and this call is idempotent, and must not return an error if all relevant resources have already been reclaimed. And in that call it will send a SIGKILL signal first to try to stop the container, thus once the container has terminated, here should ignore this signal and return directly. Fixes:#1672 Signed-off-by: lifupan <lifupan@gmail.com>
1 parent 5e1f5ca commit 0d535f5

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

containerd-shim-v2/service.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,20 @@ func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.E
677677
return nil, err
678678
}
679679

680+
// According to CRI specs, kubelet will call StopPodSandbox()
681+
// at least once before calling RemovePodSandbox, and this call
682+
// is idempotent, and must not return an error if all relevant
683+
// resources have already been reclaimed. And in that call it will
684+
// send a SIGKILL signal first to try to stop the container, thus
685+
// once the container has terminated, here should ignore this signal
686+
// and return directly.
687+
if signum == syscall.SIGKILL || signum == syscall.SIGTERM {
688+
if c.status == task.StatusStopped {
689+
logrus.WithField("sandbox", s.sandbox.ID()).WithField("Container", c.id).Debug("Container has already been stopped")
690+
return empty, nil
691+
}
692+
}
693+
680694
processID := c.id
681695
if r.ExecID != "" {
682696
execs, err := c.getExec(r.ExecID)

0 commit comments

Comments
 (0)