From 6f1440a3ec16dfbf644acb87012967bc297ec975 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 8 Jun 2020 15:15:16 -0400 Subject: Add support for the unless-stopped restart policy We initially believed that implementing this required support for restarting containers after reboot, but this is not the case. The unless-stopped restart policy acts identically to the always restart policy except in cases related to reboot (which we do not support yet), but it does not require that support for us to implement it. Changes themselves are quite simple, we need a new restart policy constant, we need to remove existing checks that block creation of containers when unless-stopped was used, and we need to update the manpages. Fixes #6508 Signed-off-by: Matthew Heon --- libpod/container.go | 4 ++++ libpod/options.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/container.go b/libpod/container.go index d4a779b13..20702903e 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -97,6 +97,10 @@ const ( // RestartPolicyOnFailure restarts the container on non-0 exit code, // with an optional maximum number of retries. RestartPolicyOnFailure = "on-failure" + // RestartPolicyUnlessStopped unconditionally restarts unless stopped + // by the user. It is identical to Always except with respect to + // handling of system restart, which Podman does not yet support. + RestartPolicyUnlessStopped = "unless-stopped" ) // Container is a single OCI container. diff --git a/libpod/options.go b/libpod/options.go index 5a0f60093..e1c4ddf06 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -1285,7 +1285,7 @@ func WithRestartPolicy(policy string) CtrCreateOption { } switch policy { - case RestartPolicyNone, RestartPolicyNo, RestartPolicyOnFailure, RestartPolicyAlways: + case RestartPolicyNone, RestartPolicyNo, RestartPolicyOnFailure, RestartPolicyAlways, RestartPolicyUnlessStopped: ctr.config.RestartPolicy = policy default: return errors.Wrapf(define.ErrInvalidArg, "%q is not a valid restart policy", policy) -- cgit v1.2.3-54-g00ecf