mirror of
https://github.com/containers/podman.git
synced 2025-06-27 05:26:50 +08:00
Fix remote integration for healthchecks
the one remaining test that is still skipped do to missing exec function Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/containers/libpod/libpod"
|
||||
"github.com/containers/libpod/libpod/define"
|
||||
"github.com/containers/libpod/pkg/api/handlers/utils"
|
||||
)
|
||||
|
||||
@ -12,32 +13,27 @@ func RunHealthCheck(w http.ResponseWriter, r *http.Request) {
|
||||
name := utils.GetName(r)
|
||||
status, err := runtime.HealthCheck(name)
|
||||
if err != nil {
|
||||
if status == libpod.HealthCheckContainerNotFound {
|
||||
if status == define.HealthCheckContainerNotFound {
|
||||
utils.ContainerNotFound(w, name, err)
|
||||
return
|
||||
}
|
||||
if status == libpod.HealthCheckNotDefined {
|
||||
if status == define.HealthCheckNotDefined {
|
||||
utils.Error(w, "no healthcheck defined", http.StatusConflict, err)
|
||||
return
|
||||
}
|
||||
if status == libpod.HealthCheckContainerStopped {
|
||||
if status == define.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
|
||||
hcStatus := define.HealthCheckUnhealthy
|
||||
if status == define.HealthCheckSuccess {
|
||||
hcStatus = define.HealthCheckHealthy
|
||||
}
|
||||
|
||||
hcLog, err := ctr.GetHealthCheckLog()
|
||||
if err != nil {
|
||||
utils.InternalServerError(w, err)
|
||||
return
|
||||
report := define.HealthCheckResults{
|
||||
Status: hcStatus,
|
||||
}
|
||||
|
||||
utils.WriteResponse(w, http.StatusOK, hcLog)
|
||||
utils.WriteResponse(w, http.StatusOK, report)
|
||||
}
|
||||
|
Reference in New Issue
Block a user