Skip to content

Commit

Permalink
Inspecting Containers without health checks return health {}
Browse files Browse the repository at this point in the history
Fixed: containers#18792

This will match Docker behaviour.
`
Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Jun 12, 2023
1 parent 77d2ae9 commit d35ebce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions libpod/define/container_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ func (s *InspectContainerState) Healthcheck() HealthCheckResults {
// HealthCheckResults describes the results/logs from a healthcheck
type HealthCheckResults struct {
// Status starting, healthy or unhealthy
Status string `json:"Status"`
Status string `json:"Status,omitempty"`
// FailingStreak is the number of consecutive failed healthchecks
FailingStreak int `json:"FailingStreak"`
FailingStreak int `json:"FailingStreak,omitzero,omitempty"`
// Log describes healthcheck attempts and results
Log []HealthCheckLog `json:"Log"`
Log []HealthCheckLog `json:"Log,omitempty"`
}

// HealthCheckLog describes the results of a single healthcheck
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/healthcheck_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ var _ = Describe("Podman healthcheck run", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--no-healthcheck", "--name", "hc", HEALTHCHECK_IMAGE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Health.Status}}", "hc"})
hc := podmanTest.Podman([]string{"container", "inspect", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc.OutputToString()).To(Not(ContainSubstring("starting")))
Expect(hc.OutputToString()).To(ContainSubstring("\"Health\": {},"))
})

It("podman run healthcheck and logs should contain healthcheck output", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/system/220-healthcheck.bats
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function _check_health {

_check_health "All healthy" "
Status | \"healthy\"
FailingStreak | 0
FailingStreak | null
Log[-1].ExitCode | 0
Log[-1].Output | \"Life is Good on stdout\\\nLife is Good on stderr\"
"
Expand Down

0 comments on commit d35ebce

Please sign in to comment.