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

healthcheck: stop showing wrong status when --no-healthcheck is set #13585

Merged
merged 1 commit into from
Mar 22, 2022
Merged
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
5 changes: 4 additions & 1 deletion libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,10 @@ func (c *Container) start() error {
}
}

if c.config.HealthCheckConfig != nil {
// Check if healthcheck is not nil and --no-healthcheck option is not set.
// If --no-healthcheck is set Test will be always set to `[NONE]` so no need
// to update status in such case.
if c.config.HealthCheckConfig != nil && !(len(c.config.HealthCheckConfig.Test) == 1 && c.config.HealthCheckConfig.Test[0] == "NONE") {
Copy link
Member

Choose a reason for hiding this comment

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

Could len(c.config.HealthCheckConfig.Test) > 1 and still have a value somewhere of "none"? If so what should we do there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rhatdan Then most likely its manually done by user and its not set via --no-healthcheck so that case should not be treated as equivalent to --no-healthcheck IMO.

Copy link
Member

Choose a reason for hiding this comment

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

Should --no-healthcheck conflict with --health-cmd then?

Copy link
Member

Choose a reason for hiding this comment

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

yes, but that check should probably be much much further up the stack imho

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@baude is correct I think we already have a conflict check for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if err := c.updateHealthStatus(define.HealthCheckStarting); err != nil {
logrus.Error(err)
}
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/healthcheck_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ var _ = Describe("Podman healthcheck run", func() {
Expect(hc).Should(Exit(125))
})

It("podman disable healthcheck with --no-healthcheck must not show starting on status", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--no-healthcheck", "--name", "hc", healthcheck})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Health.Status}}", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc.OutputToString()).To(Not(ContainSubstring("starting")))
})

It("podman run healthcheck and logs should contain healthcheck output", func() {
session := podmanTest.Podman([]string{"run", "--name", "test-logs", "-dt", "--health-interval", "1s", "--health-cmd", "echo working", "busybox", "sleep", "3600"})
session.WaitWithDefaultTimeout()
Expand Down