Skip to content

Commit

Permalink
Merge pull request #11609 from sankalp-r/add-healthcheck-ps
Browse files Browse the repository at this point in the history
added healthcheck to ps command
  • Loading branch information
openshift-merge-robot authored Sep 24, 2021
2 parents 5b88e8b + 1e0039a commit e19a09c
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 e19a09c

Please sign in to comment.