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

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

Open cedric-appdirect opened this issue 1 year ago • 0 comments

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 avatar May 17 '24 00:05 cedric-appdirect