Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspecting Containers without health checks return health nil #18807

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omitzero is not needed, please remove it. Only the toml parser uses omitzero.

// 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I think this might not be a good idea then after all.
If we hide the FailingStreak 0 even when there is a health check we could break parsers.

Log[-1].ExitCode | 0
Log[-1].Output | \"Life is Good on stdout\\\nLife is Good on stderr\"
"
Expand Down