Skip to content

Commit

Permalink
Unconditionally remove conmon files before starting
Browse files Browse the repository at this point in the history
We've been seeing a lot of issues (ref: containers#4061, but there are
others) where Podman hiccups on trying to start a container,
because some temporary files have been retained and Conmon will
not overwrite them.

If we're calling start() we can safely assume that we really want
those files gone so the container starts without error, so invoke
the cleanup routine. It's relatively cheap (four file removes) so
it shouldn't hurt us that much.

Also contains a small simplification to the removeConmonFiles
logic - we don't need to stat-then-remove when ignoring ENOENT is
fine.

Signed-off-by: Matthew Heon <[email protected]>
  • Loading branch information
mheon committed Sep 20, 2019
1 parent 9dc764c commit 407fba4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,14 +646,8 @@ func (c *Container) removeConmonFiles() error {

// Remove the exit file so we don't leak memory in tmpfs
exitFile := filepath.Join(c.ociRuntime.exitsDir, c.ID())
if _, err := os.Stat(exitFile); err != nil {
if !os.IsNotExist(err) {
return errors.Wrapf(err, "error running stat on container %s exit file", c.ID())
}
} else {
if err := os.Remove(exitFile); err != nil {
return errors.Wrapf(err, "error removing container %s exit file", c.ID())
}
if err := os.Remove(exitFile); err != nil && !os.IsNotExist(err) {
return errors.Wrapf(err, "error removing container %s exit file", c.ID())
}

return nil
Expand Down Expand Up @@ -922,6 +916,12 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
span.SetTag("struct", "container")
defer span.Finish()

// Unconditionally remove conmon temporary files.
// We've been running into far too many issues where they block startup.
if err := c.removeConmonFiles(); err != nil {
return err
}

// Generate the OCI newSpec
newSpec, err := c.generateSpec(ctx)
if err != nil {
Expand Down

0 comments on commit 407fba4

Please sign in to comment.