summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-04-03 10:24:35 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-05-03 10:36:16 -0400
commit56356d70276bed453bfe67fee068a14b7c727b2f (patch)
tree1980a7483be8e6a38a7434582a303e8e3f06af5a
parent948fb5ee64e1be8ad4ec5a748059fa45e73e2fe1 (diff)
downloadpodman-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>
-rw-r--r--libpod/container_internal.go8
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)