mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-07 14:37:43 +00:00
notifyproxy: fix container watcher
The notify proxy has a watcher to check whether the container has left the running state. In that case, Podman should stop waiting for the ready message to prevent a dead lock. Fix this watcher but adding a loop. Fixes the dead lock in #16076 surfacing in a timeout. The underlying issue persists though. Also use a timer in the select statement to prevent the goroutine from running unnecessarily long [NO NEW TESTS NEEDED] Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
parent
1b9447086f
commit
c4ebe9e2ad
1 changed files with 13 additions and 12 deletions
|
|
@ -183,20 +183,21 @@ func (p *NotifyProxy) WaitAndClose() error {
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
go func() {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
state, err := p.container.State()
|
||||
if err != nil {
|
||||
p.errorChan <- err
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(time.Second):
|
||||
state, err := p.container.State()
|
||||
if err != nil {
|
||||
p.errorChan <- err
|
||||
return
|
||||
}
|
||||
if state != define.ContainerStateRunning {
|
||||
p.errorChan <- fmt.Errorf("%w: %s", ErrNoReadyMessage, p.container.ID())
|
||||
return
|
||||
}
|
||||
}
|
||||
if state != define.ContainerStateRunning {
|
||||
p.errorChan <- fmt.Errorf("%w: %s", ErrNoReadyMessage, p.container.ID())
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue