summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-11-06 09:55:40 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2020-11-20 13:55:19 -0500
commitdc8996ec84ffd6f272361edbf7c19e91c52519d9 (patch)
tree77365b93b7f2652ff2a6314a1edc98c5f3f8913d /libpod/container_api.go
parent864fe21ed02ca6faa72e6a94f06c9961167aca7d (diff)
downloadpodman-dc8996ec84ffd6f272361edbf7c19e91c52519d9.tar.gz
podman-dc8996ec84ffd6f272361edbf7c19e91c52519d9.tar.bz2
podman-dc8996ec84ffd6f272361edbf7c19e91c52519d9.zip
Allow containers to --restart on-failure with --rm
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index a9808a30e..6a7ddc421 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -714,3 +714,17 @@ func (c *Container) Restore(ctx context.Context, options ContainerCheckpointOpti
defer c.newContainerEvent(events.Restore)
return c.restore(ctx, options)
}
+
+// Indicate whether or not the container should restart
+func (c *Container) ShouldRestart(ctx context.Context) bool {
+ logrus.Debugf("Checking if container %s should restart", c.ID())
+ if !c.batched {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ if err := c.syncContainer(); err != nil {
+ return false
+ }
+ }
+ return c.shouldRestart()
+}