Restart policy should not run if a container is running

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
Matthew Heon 2019-04-03 10:24:35 -04:00
parent 948fb5ee64
commit 56356d7027
1 changed files with 8 additions and 0 deletions

View File

@ -221,6 +221,14 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (err error) {
return err 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 // Increment restart count
c.state.RestartCount = c.state.RestartCount + 1 c.state.RestartCount = c.state.RestartCount + 1
logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount) logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount)