Skip to content

Commit c4ebe9e

Browse files
committed
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 <[email protected]>
1 parent 1b94470 commit c4ebe9e

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

pkg/systemd/notifyproxy/notifyproxy.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,21 @@ func (p *NotifyProxy) WaitAndClose() error {
183183
ctx, cancel := context.WithCancel(context.Background())
184184
defer cancel()
185185
go func() {
186-
select {
187-
case <-ctx.Done():
188-
return
189-
default:
190-
state, err := p.container.State()
191-
if err != nil {
192-
p.errorChan <- err
193-
return
194-
}
195-
if state != define.ContainerStateRunning {
196-
p.errorChan <- fmt.Errorf("%w: %s", ErrNoReadyMessage, p.container.ID())
186+
for {
187+
select {
188+
case <-ctx.Done():
197189
return
190+
case <-time.After(time.Second):
191+
state, err := p.container.State()
192+
if err != nil {
193+
p.errorChan <- err
194+
return
195+
}
196+
if state != define.ContainerStateRunning {
197+
p.errorChan <- fmt.Errorf("%w: %s", ErrNoReadyMessage, p.container.ID())
198+
return
199+
}
198200
}
199-
time.Sleep(time.Second)
200201
}
201202
}()
202203
}

0 commit comments

Comments
 (0)