Skip to content

Commit e19a09c

Browse files
Merge pull request #11609 from sankalp-r/add-healthcheck-ps
added healthcheck to ps command
2 parents 5b88e8b + 1e0039a commit e19a09c

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

cmd/podman/containers/ps.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ func (l psReporter) State() string {
375375

376376
// Status is a synonym for State()
377377
func (l psReporter) Status() string {
378+
hc := l.ListContainer.Status
379+
if hc != "" {
380+
return l.State() + " (" + hc + ")"
381+
}
378382
return l.State()
379383
}
380384

pkg/ps/ps.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
241241
UTS: uts,
242242
}
243243
}
244+
245+
if hc, err := ctr.HealthCheckStatus(); err == nil {
246+
ps.Status = hc
247+
} else {
248+
logrus.Debug(err)
249+
}
250+
244251
return ps, nil
245252
}
246253

test/e2e/healthcheck_run_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ var _ = Describe("Podman healthcheck run", func() {
8080
time.Sleep(1 * time.Second)
8181
}
8282
Expect(exitCode).To(Equal(0))
83+
84+
ps := podmanTest.Podman([]string{"ps"})
85+
ps.WaitWithDefaultTimeout()
86+
Expect(ps).Should(Exit(0))
87+
Expect(ps.OutputToString()).To(ContainSubstring("(healthy)"))
8388
})
8489

8590
It("podman healthcheck that should fail", func() {

0 commit comments

Comments
 (0)