From b66287689a0c8c9f2f8c01cdca065fb1f6e8d872 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 6 Dec 2017 11:15:17 -0500 Subject: Do not recreate containers in runc after restart Signed-off-by: Matthew Heon --- libpod/container.go | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/libpod/container.go b/libpod/container.go index d12167d15..adc52d85f 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -428,23 +428,11 @@ func (c *Container) refresh() error { c.state.Mounted = false c.state.Mountpoint = "" - // The container is no longe running + // The container is no longer running c.state.PID = 0 - // Check the container's state. If it's not created in runc yet, we're - // done - if c.state.State == ContainerStateConfigured { - if err := c.runtime.state.SaveContainer(c); err != nil { - return errors.Wrapf(err, "error refreshing state for container %s", c.ID()) - } - - return nil - } - - // The container must be recreated in runc - if err := c.init(); err != nil { - return err - } + // The container no longer exists in runc + c.state.State = ContainerStateConfigured if err := c.runtime.state.SaveContainer(c); err != nil { return errors.Wrapf(err, "error refreshing state for container %s", c.ID()) @@ -454,7 +442,7 @@ func (c *Container) refresh() error { } // Init creates a container in the OCI runtime -func (c *Container) Init() error { +func (c *Container) Init() (err error) { c.lock.Lock() defer c.lock.Unlock() @@ -466,12 +454,6 @@ func (c *Container) Init() error { return errors.Wrapf(ErrCtrExists, "container %s has already been created in runtime", c.ID()) } - return c.init() -} - -// Creates container in OCI runtime -// Internal only - does not lock or check state -func (c *Container) init() (err error) { if err := c.mountStorage(); err != nil { return err } -- cgit v1.2.3-54-g00ecf