testcontainers-go icon indicating copy to clipboard operation
testcontainers-go copied to clipboard

[Bug]: hijacked connection returned by ContainerExecAttach is not closed

Open AlexanderYastrebov opened this issue 2 years ago • 1 comments

Testcontainers version

v0.21.0

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host arch

x86

Go version

1.20

Docker version

-

Docker info

-

What happened?

Here https://github.com/testcontainers/testcontainers-go/blob/f5a4a541f71a324d1bf81f40700e5426259dbae6/docker.go#L485-L492 cli.ContainerExecAttach returns hijacked connections which should be closed by the caller:

It's up to the called to close the hijacked connection by calling types.HijackedResponse.Close.

Unfortunately Exec returns io.Reader https://github.com/testcontainers/testcontainers-go/blob/f5a4a541f71a324d1bf81f40700e5426259dbae6/container.go#L51

I think it should return io.ReadCloser that closes hijacked connection on Close()

See related #321

Relevant log output

No response

Additional information

No response

AlexanderYastrebov avatar Jul 10 '23 17:07 AlexanderYastrebov

Hi @AlexanderYastrebov thanks for reporting this. I now understand the issue with the Exec function not returning a ReadCloser.

I think we can update the signature as a breaking change in an upcoming minor release if needed, although I'm planning to start working on a v1 branch for an eventual v1.0.0 release of tc-go.

mdelapenya avatar Aug 02 '23 16:08 mdelapenya