added healthcheck to ps command

Signed-off-by: Sankalp Rangare <sankalprangare786@gmail.com>
This commit is contained in:
Sankalp Rangare
2021-09-16 20:34:39 +05:30
parent 800d594afa
commit 1e0039a839
3 changed files with 16 additions and 0 deletions

View File

@ -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()
}

View File

@ -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
}

View File

@ -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() {