summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-05 16:36:49 +0200
committerGitHub <noreply@github.com>2019-08-05 16:36:49 +0200
commit6997dc14886b62c5baef50ba38ce2538ee238019 (patch)
tree3d8040fd7cc7cf12866076219afdcc5caa1aab18 /libpod
parent337358ae63f5b6c5f73ee399918aa4b7c8059f85 (diff)
parent909ab594191ce964529398bcf7600edff9540d71 (diff)
downloadpodman-6997dc14886b62c5baef50ba38ce2538ee238019.tar.gz
podman-6997dc14886b62c5baef50ba38ce2538ee238019.tar.bz2
podman-6997dc14886b62c5baef50ba38ce2538ee238019.zip
Merge pull request #3701 from vrothberg/fix-3696
container stop: kill conmon
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index aba9c5b93..313f67963 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -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 {