mirror of
https://github.com/containers/podman.git
synced 2025-06-22 18:08:11 +08:00
Merge pull request #20132 from cgiradkar/Issue-17856
Change log level for health_check
This commit is contained in:
@ -401,7 +401,7 @@ func (c *Container) execStartAndAttach(sessionID string, streams *define.AttachS
|
||||
|
||||
logrus.Debugf("Container %s exec session %s completed with exit code %d", c.ID(), session.ID(), exitCode)
|
||||
|
||||
if err := justWriteExecExitCode(c, session.ID(), exitCode); err != nil {
|
||||
if err := justWriteExecExitCode(c, session.ID(), exitCode, !isHealthcheck); err != nil {
|
||||
if lastErr != nil {
|
||||
logrus.Errorf("Container %s exec session %s error: %v", c.ID(), session.ID(), lastErr)
|
||||
}
|
||||
@ -1114,7 +1114,7 @@ func writeExecExitCode(c *Container, sessionID string, exitCode int) error {
|
||||
return fmt.Errorf("syncing container %s state to remove exec session %s: %w", c.ID(), sessionID, err)
|
||||
}
|
||||
|
||||
return justWriteExecExitCode(c, sessionID, exitCode)
|
||||
return justWriteExecExitCode(c, sessionID, exitCode, true)
|
||||
}
|
||||
|
||||
func retrieveAndWriteExecExitCode(c *Container, sessionID string) error {
|
||||
@ -1123,12 +1123,14 @@ func retrieveAndWriteExecExitCode(c *Container, sessionID string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return justWriteExecExitCode(c, sessionID, exitCode)
|
||||
return justWriteExecExitCode(c, sessionID, exitCode, true)
|
||||
}
|
||||
|
||||
func justWriteExecExitCode(c *Container, sessionID string, exitCode int) error {
|
||||
func justWriteExecExitCode(c *Container, sessionID string, exitCode int, emitEvent bool) error {
|
||||
// Write an event first
|
||||
if emitEvent {
|
||||
c.newExecDiedEvent(sessionID, exitCode)
|
||||
}
|
||||
|
||||
session, ok := c.state.ExecSessions[sessionID]
|
||||
if !ok {
|
||||
|
@ -27,7 +27,7 @@ func (c *Container) createTimer(interval string, isStartup bool) error {
|
||||
return fmt.Errorf("failed to get path for podman for a health check timer: %w", err)
|
||||
}
|
||||
|
||||
var cmd = []string{}
|
||||
var cmd = []string{"--property", "LogLevelMax=notice"}
|
||||
if rootless.IsRootless() {
|
||||
cmd = append(cmd, "--user")
|
||||
}
|
||||
|
@ -263,6 +263,20 @@ var _ = Describe("Podman healthcheck run", func() {
|
||||
Expect(ps.OutputToString()).To(ContainSubstring("hc"))
|
||||
})
|
||||
|
||||
It("hc logs do not include exec events", func() {
|
||||
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-cmd", "true", "--health-interval", "5s", "alpine", "sleep", "60"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
|
||||
hc.WaitWithDefaultTimeout()
|
||||
Expect(hc).Should(ExitCleanly())
|
||||
hcLogs := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "container=hc", "--filter", "event=exec_died", "--filter", "event=exec", "--since", "1m"})
|
||||
hcLogs.WaitWithDefaultTimeout()
|
||||
Expect(hcLogs).Should(ExitCleanly())
|
||||
hcLogsArray := hcLogs.OutputToStringArray()
|
||||
Expect(hcLogsArray).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("stopping and then starting a container with healthcheck cmd", func() {
|
||||
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-cmd", "[\"ls\", \"/foo\"]", ALPINE, "top"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
Reference in New Issue
Block a user