mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
Fix bindings container log test
The returned error was not checked, thus the test could hang forever since it blocks on the log channel. Also handle unexpectedEOF like EOF. Fixes #12176 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -214,7 +214,7 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
|
|||||||
// Read multiplexed channels and write to appropriate stream
|
// Read multiplexed channels and write to appropriate stream
|
||||||
fd, l, err := DemuxHeader(socket, buffer)
|
fd, l, err := DemuxHeader(socket, buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@ -531,7 +531,7 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, options *ExecStar
|
|||||||
// Read multiplexed channels and write to appropriate stream
|
// Read multiplexed channels and write to appropriate stream
|
||||||
fd, l, err := DemuxHeader(socket, buffer)
|
fd, l, err := DemuxHeader(socket, buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -39,7 +39,7 @@ func Logs(ctx context.Context, nameOrID string, options *LogOptions, stdoutChan,
|
|||||||
for {
|
for {
|
||||||
fd, l, err := DemuxHeader(response.Body, buffer)
|
fd, l, err := DemuxHeader(response.Body, buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -259,6 +259,7 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
_, err = bt.RunTopContainer(&name, nil)
|
_, err = bt.RunTopContainer(&name, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
go func() {
|
go func() {
|
||||||
|
defer GinkgoRecover()
|
||||||
exitCode, err = containers.Wait(bt.conn, name, nil)
|
exitCode, err = containers.Wait(bt.conn, name, nil)
|
||||||
errChan <- err
|
errChan <- err
|
||||||
close(errChan)
|
close(errChan)
|
||||||
@ -281,6 +282,7 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
_, err := bt.RunTopContainer(&name, nil)
|
_, err := bt.RunTopContainer(&name, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
go func() {
|
go func() {
|
||||||
|
defer GinkgoRecover()
|
||||||
exitCode, err = containers.Wait(bt.conn, name, new(containers.WaitOptions).WithCondition([]define.ContainerStatus{pause}))
|
exitCode, err = containers.Wait(bt.conn, name, new(containers.WaitOptions).WithCondition([]define.ContainerStatus{pause}))
|
||||||
errChan <- err
|
errChan <- err
|
||||||
close(errChan)
|
close(errChan)
|
||||||
@ -366,7 +368,10 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
|
|
||||||
opts := new(containers.LogOptions).WithStdout(true).WithFollow(true)
|
opts := new(containers.LogOptions).WithStdout(true).WithFollow(true)
|
||||||
go func() {
|
go func() {
|
||||||
containers.Logs(bt.conn, r.ID, opts, stdoutChan, nil)
|
defer GinkgoRecover()
|
||||||
|
err := containers.Logs(bt.conn, r.ID, opts, stdoutChan, nil)
|
||||||
|
close(stdoutChan)
|
||||||
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
}()
|
}()
|
||||||
o := <-stdoutChan
|
o := <-stdoutChan
|
||||||
o = strings.TrimSpace(o)
|
o = strings.TrimSpace(o)
|
||||||
|
Reference in New Issue
Block a user