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

Commit

Permalink
shimv2: kill a container return directly once the container termianted
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 0d535f5)
Signed-off-by: Ganesh Maharaj Mahalingam <[email protected]>
  • Loading branch information
lifupan authored and Ganesh Maharaj Mahalingam committed Jun 5, 2019
1 parent 377f332 commit a38b402
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,20 @@ func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.E
return nil, err
}

// 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.
if signum == syscall.SIGKILL || signum == syscall.SIGTERM {
if c.status == task.StatusStopped {
logrus.WithField("sandbox", s.sandbox.ID()).WithField("Container", c.id).Debug("Container has already been stopped")
return empty, nil
}
}

processID := c.id
if r.ExecID != "" {
execs, err := c.getExec(r.ExecID)
Expand Down

0 comments on commit a38b402

Please sign in to comment.