mirror of
https://github.com/containers/podman.git
synced 2025-06-25 03:52:15 +08:00
Merge pull request #3701 from vrothberg/fix-3696
container stop: kill conmon
This commit is contained in:
@ -1152,9 +1152,27 @@ func (c *Container) restartWithTimeout(ctx context.Context, timeout uint) (err e
|
||||
c.newContainerEvent(events.Restart)
|
||||
|
||||
if c.state.State == define.ContainerStateRunning {
|
||||
conmonPID := c.state.ConmonPID
|
||||
if err := c.stop(timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
// Old versions of conmon have a bug where they create the exit file before
|
||||
// closing open file descriptors causing a race condition when restarting
|
||||
// containers with open ports since we cannot bind the ports as they're not
|
||||
// yet closed by conmon.
|
||||
//
|
||||
// Killing the old conmon PID is ~okay since it forces the FDs of old conmons
|
||||
// to be closed, while it's a NOP for newer versions which should have
|
||||
// exited already.
|
||||
if conmonPID != 0 {
|
||||
// Ignore errors from FindProcess() as conmon could already have exited.
|
||||
p, err := os.FindProcess(conmonPID)
|
||||
if p != nil && err == nil {
|
||||
if err = p.Kill(); err != nil {
|
||||
logrus.Debugf("error killing conmon process: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user