diff --git a/pkg/systemd/notifyproxy/notifyproxy.go b/pkg/systemd/notifyproxy/notifyproxy.go index e9dd48c51b..b5010cbc85 100644 --- a/pkg/systemd/notifyproxy/notifyproxy.go +++ b/pkg/systemd/notifyproxy/notifyproxy.go @@ -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) } }() }