X Tutup
Skip to content

Commit 7078e50

Browse files
authored
Merge pull request containerd#6572 from fuweid/cp-1.6-6452-6571
[release/1.6] runc.v1/v2: return init pid when clean dead shim
2 parents 39259a8 + 444eba4 commit 7078e50

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

runtime/v2/runc/manager/manager_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,13 @@ func (manager) Stop(ctx context.Context, id string) (shim.StopStatus, error) {
270270
if err := mount.UnmountAll(filepath.Join(path, "rootfs"), 0); err != nil {
271271
log.G(ctx).WithError(err).Warn("failed to cleanup rootfs mount")
272272
}
273+
pid, err := runcC.ReadPidFile(filepath.Join(path, process.InitPidFile))
274+
if err != nil {
275+
log.G(ctx).WithError(err).Warn("failed to read init pid file")
276+
}
273277
return shim.StopStatus{
274278
ExitedAt: time.Now(),
275279
ExitStatus: 128 + int(unix.SIGKILL),
280+
Pid: pid,
276281
}, nil
277282
}

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)
X Tutup