mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
compat attach: fix write on closed channel
Waiting on an initialized sync.WaitGroup returns immediately. Hence, move the goroutine to wait and close *after* reading the logs. Fixes: #12904 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -660,13 +660,13 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http.
|
||||
}
|
||||
errChan <- err
|
||||
}()
|
||||
if err := ctr.ReadLog(context.Background(), logOpts, logChan); err != nil {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
logOpts.WaitGroup.Wait()
|
||||
close(logChan)
|
||||
}()
|
||||
if err := ctr.ReadLog(context.Background(), logOpts, logChan); err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Debugf("Done reading logs for container %s, %d bytes", ctr.ID(), logSize)
|
||||
if err := <-errChan; err != nil {
|
||||
return err
|
||||
|
@ -130,7 +130,7 @@ class ContainerTestCase(APITestCase):
|
||||
|
||||
def test_attach(self):
|
||||
self.skipTest("FIXME: Test timeouts")
|
||||
r = requests.post(self.uri(self.resolve_container("/containers/{}/attach")), timeout=5)
|
||||
r = requests.post(self.uri(self.resolve_container("/containers/{}/attach?logs=true")), timeout=5)
|
||||
self.assertIn(r.status_code, (101, 500), r.text)
|
||||
|
||||
def test_logs(self):
|
||||
|
Reference in New Issue
Block a user