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

added healthcheck to ps command #11609

Merged
merged 1 commit into from
Sep 24, 2021
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
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
Copy link
Member

Choose a reason for hiding this comment

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

We should at least warn on error.

Copy link
Contributor Author

@sankalp-r sankalp-r Sep 24, 2021

Choose a reason for hiding this comment

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

Adding a warning-log changes "ps" command output, which results in failure of other tests.

Copy link
Member

Choose a reason for hiding this comment

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

Then at least add it to Debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added debug-log.

} 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