mirror of
https://github.com/containers/podman.git
synced 2025-05-20 00:27:03 +08:00
libpod: wait another interval for healthcheck
wait for another interval when the container transitioned to "stopped" to give more time to the healthcheck status to change. Closes: https://github.com/containers/podman/issues/22760 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -767,7 +767,7 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
stoppedCount := 0
|
||||
for {
|
||||
if len(wantedStates) > 0 {
|
||||
state, err := c.State()
|
||||
@ -784,10 +784,17 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
||||
// even if we are interested only in the health check
|
||||
// check that the container is still running to avoid
|
||||
// waiting until the timeout expires.
|
||||
state, err := c.State()
|
||||
if err != nil {
|
||||
trySend(-1, err)
|
||||
return
|
||||
if stoppedCount > 0 {
|
||||
stoppedCount++
|
||||
} else {
|
||||
state, err := c.State()
|
||||
if err != nil {
|
||||
trySend(-1, err)
|
||||
return
|
||||
}
|
||||
if state != define.ContainerStateCreated && state != define.ContainerStateRunning && state != define.ContainerStatePaused {
|
||||
stoppedCount++
|
||||
}
|
||||
}
|
||||
status, err := c.HealthCheckStatus()
|
||||
if err != nil {
|
||||
@ -798,7 +805,9 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
||||
trySend(-1, nil)
|
||||
return
|
||||
}
|
||||
if state != define.ContainerStateCreated && state != define.ContainerStateRunning && state != define.ContainerStatePaused {
|
||||
// wait for another waitTimeout interval to give the health check process some time
|
||||
// to record the healthy status.
|
||||
if stoppedCount > 1 {
|
||||
trySend(-1, define.ErrCtrStopped)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user