diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-13 21:18:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-13 21:18:10 +0100 |
commit | 4f497991bcff59a030fc79ce54e7855d7f38be99 (patch) | |
tree | a40d66583f16581bcfd0ed2094acf478d151e442 /pkg/api/handlers/libpod/healthcheck.go | |
parent | c9f148fb154ca45081e3ebfc0c14fa9ee995780d (diff) | |
parent | 2099643aa2929e8d394c8b0fb584ad90075ad0b5 (diff) | |
download | podman-4f497991bcff59a030fc79ce54e7855d7f38be99.tar.gz podman-4f497991bcff59a030fc79ce54e7855d7f38be99.tar.bz2 podman-4f497991bcff59a030fc79ce54e7855d7f38be99.zip |
Merge pull request #5327 from baude/apiv2hc
add apiv2 healthcheck code
Diffstat (limited to 'pkg/api/handlers/libpod/healthcheck.go')
-rw-r--r-- | pkg/api/handlers/libpod/healthcheck.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/pkg/api/handlers/libpod/healthcheck.go b/pkg/api/handlers/libpod/healthcheck.go index 6c74500b9..6eb2ab0e3 100644 --- a/pkg/api/handlers/libpod/healthcheck.go +++ b/pkg/api/handlers/libpod/healthcheck.go @@ -14,8 +14,30 @@ func RunHealthCheck(w http.ResponseWriter, r *http.Request) { if err != nil { if status == libpod.HealthCheckContainerNotFound { utils.ContainerNotFound(w, name, err) + return } + if status == libpod.HealthCheckNotDefined { + utils.Error(w, "no healthcheck defined", http.StatusConflict, err) + return + } + if status == libpod.HealthCheckContainerStopped { + utils.Error(w, "container not running", http.StatusConflict, err) + return + } + utils.InternalServerError(w, err) + return + } + ctr, err := runtime.LookupContainer(name) + if err != nil { utils.InternalServerError(w, err) + return } - utils.WriteResponse(w, http.StatusOK, status) + + hcLog, err := ctr.GetHealthCheckLog() + if err != nil { + utils.InternalServerError(w, err) + return + } + + utils.WriteResponse(w, http.StatusOK, hcLog) } |