Health Check is not handled in the compat LibpodToContainerJSON

Added parsing and handling for the healthCheck status within containers.go. Also modified tests

fixes #10457

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
cdoern
2021-06-09 09:20:43 -04:00
committed by Matthew Heon
parent 949573c5a8
commit 613f427a03

View File

@ -403,6 +403,24 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
state.Status = define.ContainerStateCreated.String()
}
state.Health = &types.Health{
Status: inspect.State.Healthcheck.Status,
FailingStreak: inspect.State.Healthcheck.FailingStreak,
}
log := inspect.State.Healthcheck.Log
for _, item := range log {
res := &types.HealthcheckResult{}
s, _ := time.Parse(time.RFC3339Nano, item.Start)
e, _ := time.Parse(time.RFC3339Nano, item.End)
res.Start = s
res.End = e
res.ExitCode = item.ExitCode
res.Output = item.Output
state.Health.Log = append(state.Health.Log, res)
}
formatCapabilities(inspect.HostConfig.CapDrop)
formatCapabilities(inspect.HostConfig.CapAdd)