Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: context.Context is ignored while setting up port forwarding #2540

Closed
cedric-appdirect opened this issue May 17, 2024 · 1 comment · Fixed by #2550
Closed

[Bug]: context.Context is ignored while setting up port forwarding #2540

cedric-appdirect opened this issue May 17, 2024 · 1 comment · Fixed by #2550
Labels
bug An issue with the library

Comments

@cedric-appdirect
Copy link
Contributor

Testcontainers version

latest

Using the latest Testcontainers version?

Yes

Host OS

MacOS

Host arch

x86_64

Go version

1.22

Docker version

Docker version 24.0.7, build afdd53b

Docker info

Client:
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.0-desktop.2
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.23.3-desktop.2
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.21
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  0.1
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.10
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-scan
  scout: Docker Scout (Docker Inc.)
    Version:  v1.2.0
    Path:     /Users/cedric.bail/.docker/cli-plugins/docker-scout

Server:
 Containers: 23
  Running: 9
  Paused: 0
  Stopped: 14
 Images: 69
 Server Version: 24.0.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.5.11-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 7.665GiB
 Name: docker-desktop
 ID: 6b3eceaa-f712-4307-b18a-43cb7876dcdb
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

What happened?

When calling testcontainers.GenericContainer the passed ctx is ignored when reaching port forwarding logic at: https://github.com/testcontainers/testcontainers-go/blob/main/port_forwarding.go#L236 .

Relevant log output

No response

Additional information

I think a select against ctx.Done should be done in parallel to waiting on <-pfw.connectionCreated and should exit early returning ctx.Err(). If that sounds like an acceptable solution I could do a PR tomorrow.

@cedric-appdirect cedric-appdirect added the bug An issue with the library label May 17, 2024
@cedric-appdirect
Copy link
Contributor Author

Further diving in the code, I think the correct solution is to handle error properly from Forward when creating the ssh connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant