summaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-11-23 13:44:37 +0100
committerGitHub <noreply@github.com>2020-11-23 13:44:37 +0100
commitdd343418ce5a3fd6c6238d7e2edc132826756051 (patch)
tree8f6f33d7e8faed4bf8201d655a54a7277282820f /pkg/api
parentac55bd1f673156cbb60b568b65f7bf4918daf152 (diff)
parentdc8996ec84ffd6f272361edbf7c19e91c52519d9 (diff)
downloadpodman-dd343418ce5a3fd6c6238d7e2edc132826756051.tar.gz
podman-dd343418ce5a3fd6c6238d7e2edc132826756051.tar.bz2
podman-dd343418ce5a3fd6c6238d7e2edc132826756051.zip
Merge pull request #8263 from rhatdan/restart
Allow containers to --restart on-failure with --rm
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/handlers/libpod/containers.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/api/handlers/libpod/containers.go b/pkg/api/handlers/libpod/containers.go
index 7e6481321..14eb44831 100644
--- a/pkg/api/handlers/libpod/containers.go
+++ b/pkg/api/handlers/libpod/containers.go
@@ -344,3 +344,27 @@ func InitContainer(w http.ResponseWriter, r *http.Request) {
}
utils.WriteResponse(w, http.StatusNoContent, "")
}
+
+func ShouldRestart(w http.ResponseWriter, r *http.Request) {
+ runtime := r.Context().Value("runtime").(*libpod.Runtime)
+ // Now use the ABI implementation to prevent us from having duplicate
+ // code.
+ containerEngine := abi.ContainerEngine{Libpod: runtime}
+
+ name := utils.GetName(r)
+ report, err := containerEngine.ShouldRestart(r.Context(), name)
+ if err != nil {
+ if errors.Cause(err) == define.ErrNoSuchCtr {
+ utils.ContainerNotFound(w, name, err)
+ return
+ }
+ utils.InternalServerError(w, err)
+ return
+
+ }
+ if report.Value {
+ utils.WriteResponse(w, http.StatusNoContent, "")
+ } else {
+ utils.ContainerNotFound(w, name, define.ErrNoSuchCtr)
+ }
+}