From 5e9aa13dc03e022db91135be2cb001c35eef0d08 Mon Sep 17 00:00:00 2001 From: Sankalp Rangare Date: Thu, 16 Sep 2021 20:34:39 +0530 Subject: added healthcheck to ps command Signed-off-by: Sankalp Rangare --- cmd/podman/containers/ps.go | 4 ++++ pkg/ps/ps.go | 7 +++++++ test/e2e/healthcheck_run_test.go | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 2566c57de..920ad0d4a 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -375,6 +375,10 @@ func (l psReporter) State() string { // Status is a synonym for State() func (l psReporter) Status() string { + hc := l.ListContainer.Status + if hc != "" { + return l.State() + " (" + hc + ")" + } return l.State() } diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go index 54079baa1..e65400555 100644 --- a/pkg/ps/ps.go +++ b/pkg/ps/ps.go @@ -241,6 +241,13 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities UTS: uts, } } + + if hc, err := ctr.HealthCheckStatus(); err == nil { + ps.Status = hc + } else { + logrus.Debug(err) + } + return ps, nil } diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 1445a634b..b30e8b810 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -80,6 +80,11 @@ var _ = Describe("Podman healthcheck run", func() { time.Sleep(1 * time.Second) } Expect(exitCode).To(Equal(0)) + + ps := podmanTest.Podman([]string{"ps"}) + ps.WaitWithDefaultTimeout() + Expect(ps).Should(Exit(0)) + Expect(ps.OutputToString()).To(ContainSubstring("(healthy)")) }) It("podman healthcheck that should fail", func() { -- cgit v1.2.3-54-g00ecf