Fix race condition when looking up reaper (ryuk) container by emetsger · Pull Request #2508 · testcontainers/testcontainers-go

This was referenced

Apr 22, 2024

Bablzz

@emetsger emetsger changed the title Use health status when looking up reaper (ryuk) container Fix race condition when looking up reaper (ryuk) container

May 19, 2024

lachauj

@emetsger

@emetsger

… being started by newReaper in a separate process.

A race between newReaper and lookUpReaperContainer occurs:
- newReaper creates the container with a ContainerRequest.WaitingFor = wait.ForListeningPort(listeningPort)
- newReaper starts the container
- lookUpReaperContainer obtains the container and returns.
- newReaper invokes the readiness hook wait.ForListeningPort(listeningPort).

@emetsger

mdelapenya

@mdelapenya

@mdelapenya

@mdelapenya

@mdelapenya

mdelapenya

mdelapenya added a commit that referenced this pull request

Jun 10, 2024
* If the ryuk container has a health status, wait for a healthy container before returning.

* Use docker/types for health status, but also check for the zero value.

* Wait for the ryuk port to be available in case the container is still being started by newReaper in a separate process.

A race between newReaper and lookUpReaperContainer occurs:
- newReaper creates the container with a ContainerRequest.WaitingFor = wait.ForListeningPort(listeningPort)
- newReaper starts the container
- lookUpReaperContainer obtains the container and returns.
- newReaper invokes the readiness hook wait.ForListeningPort(listeningPort).

* Fix whitespace.

* chore: simplify

* chore: make lint

* chore: change emoji in log output when waiting

* chore: move inside reuseReaper

---------

Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>

mdelapenya added a commit to bearrito/testcontainers-go that referenced this pull request

Jun 11, 2024

mdelapenya added a commit that referenced this pull request

Jun 18, 2024
* If the ryuk container has a health status, wait for a healthy container before returning.

* Use docker/types for health status, but also check for the zero value.

* Wait for the ryuk port to be available in case the container is still being started by newReaper in a separate process.

A race between newReaper and lookUpReaperContainer occurs:
- newReaper creates the container with a ContainerRequest.WaitingFor = wait.ForListeningPort(listeningPort)
- newReaper starts the container
- lookUpReaperContainer obtains the container and returns.
- newReaper invokes the readiness hook wait.ForListeningPort(listeningPort).

* Fix whitespace.

* chore: simplify

* chore: make lint

* chore: change emoji in log output when waiting

* chore: move inside reuseReaper

---------

Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>

mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request

Jun 24, 2024