From 56356d70276bed453bfe67fee068a14b7c727b2f Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 3 Apr 2019 10:24:35 -0400 Subject: Restart policy should not run if a container is running Signed-off-by: Matthew Heon --- libpod/container_internal.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libpod') diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 76de37a09..22ed34987 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -221,6 +221,14 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (err error) { return err } + // Is the container running again? + // If so, we don't have to do anything + if c.state.State == ContainerStateRunning || c.state.State == ContainerStatePaused { + return nil + } else if c.state.State == ContainerStateUnknown { + return errors.Wrapf(ErrInternal, "invalid container state encountered in restart attempt!") + } + // Increment restart count c.state.RestartCount = c.state.RestartCount + 1 logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount) -- cgit v1.2.3-54-g00ecf