Skip to content

Commit

Permalink
added healthcheck to ps command
Browse files Browse the repository at this point in the history
Signed-off-by: Sankalp Rangare <[email protected]>
  • Loading branch information
sankalp-r committed Sep 24, 2021
1 parent 800d594 commit 1e0039a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/podman/containers/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/ps/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions test/e2e/healthcheck_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 1e0039a

Please sign in to comment.