Skip to content

Commit 7901f4b

Browse files
committed
containerd-shim-runc-v1: return init pid when clean dead shim
If containerd-shim-runc-v1 process dead abnormally, such as received kill -s 9 signal, panic or other unkown reasons, the containerd-shim-runc-v1 server can not reap runc container and forward init process exit event. This will lead the container leaked in dockerd. When shim dead, containerd will clean dead shim, here read init process pid and forward exit event with pid at the same time. Related to: containerd#6402 Signed-off-by: Jeff Zvier <zvier20@gmail.com> Signed-off-by: Wei Fu <fuweid89@gmail.com>
1 parent c0bbaf5 commit 7901f4b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

runtime/v2/runc/v1/service.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,16 @@ func (s *service) Cleanup(ctx context.Context) (*taskAPI.DeleteResponse, error)
259259
if err := mount.UnmountAll(filepath.Join(path, "rootfs"), 0); err != nil {
260260
logrus.WithError(err).Warn("failed to cleanup rootfs mount")
261261
}
262+
263+
pid, err := runcC.ReadPidFile(filepath.Join(path, process.InitPidFile))
264+
if err != nil {
265+
logrus.WithError(err).Warn("failed to read init pid file")
266+
}
267+
262268
return &taskAPI.DeleteResponse{
263269
ExitedAt: time.Now(),
264270
ExitStatus: 128 + uint32(unix.SIGKILL),
271+
Pid: uint32(pid),
265272
}, nil
266273
}
267274

0 commit comments

Comments
 (0)