Skip to content

Commit

Permalink
notifyproxy: fix container watcher
Browse files Browse the repository at this point in the history
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 containers#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>
  • Loading branch information
vrothberg committed Oct 25, 2022
1 parent 1b94470 commit c4ebe9e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pkg/systemd/notifyproxy/notifyproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
return
}
if state != define.ContainerStateRunning {
p.errorChan <- fmt.Errorf("%w: %s", ErrNoReadyMessage, p.container.ID())
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
}
}
time.Sleep(time.Second)
}
}()
}
Expand Down

0 comments on commit c4ebe9e

Please sign in to comment.