diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-04-03 10:24:35 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-05-03 10:36:16 -0400 |
commit | 56356d70276bed453bfe67fee068a14b7c727b2f (patch) | |
tree | 1980a7483be8e6a38a7434582a303e8e3f06af5a /libpod | |
parent | 948fb5ee64e1be8ad4ec5a748059fa45e73e2fe1 (diff) | |
download | podman-56356d70276bed453bfe67fee068a14b7c727b2f.tar.gz podman-56356d70276bed453bfe67fee068a14b7c727b2f.tar.bz2 podman-56356d70276bed453bfe67fee068a14b7c727b2f.zip |
Restart policy should not run if a container is running
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal.go | 8 |
1 files changed, 8 insertions, 0 deletions
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) |