Skip to content

The cleanup is missing between the startup attempts #2877

Closed
@vmassol

Description

@vmassol

When BrowserWebDriverContainer#containerIsStarted() fails to construct the WebDriver object, TC tries to restart it, up to 3 times, leading to several containers running.

This is because GenericContainer#doStart()does:

            Unreliables.retryUntilSuccess(startupAttempts, () -> {
                logger().debug("Trying to start container: {} (attempt {}/{})", getDockerImageName(), attempt.incrementAndGet(), startupAttempts);
                tryStart(startedAt);
                return true;
            });

And BrowserWebDriverContainer has a retry set to 3 (see https://github.com/testcontainers/testcontainers-java/blob/master/modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java#L191).

So if containerIsStarted() fails then tryStart() fails and thus it's called again.

Leading to seeing the following for example, where you can see 2 BrowserWebDriverContainer containers:

$ sudo docker ps -a
CONTAINER ID        IMAGE                                        COMMAND                   CREATED             STATUS              PORTS                                              NAMES
cff188572636        testcontainersofficial/vnc-recorder:1.1.0    "/bin/sh -c 'echo 'c…"    24 seconds ago      Up 19 seconds                                                          xenodochial_galileo
03f13169c6c4        selenium/standalone-firefox-debug:3.141.59   "/opt/bin/entry_poin…"    5 minutes ago       Up 5 minutes        0.0.0.0:37893->4444/tcp, 0.0.0.0:37892->5900/tcp   compassionate_leavitt
ceef840e2bc0        selenium/standalone-firefox-debug:3.141.59   "/opt/bin/entry_poin…"    6 minutes ago       Up 5 minutes        0.0.0.0:37889->4444/tcp, 0.0.0.0:37888->5900/tcp   wizardly_bell
ac259d89690e        testcontainersofficial/sshd:1.0.0            "sh -c 'echo \"root:$…"   8 minutes ago       Up 8 minutes        0.0.0.0:37885->22/tcp                              wonderful_visvesvaraya
37a11f5e2228        testcontainersofficial/ryuk:0.3.0            "/app"                    8 minutes ago       Up 8 minutes        0.0.0.0:37884->8080/tcp                            testcontainers-ryuk-4e2447ec-fcf9-409a-827f-3c35953890d3
b1f5c0da7be5        xwiki/build:jessie                           "setup-xwiki-ssh /bi…"    About an hour ago   Up About an hour    22/tcp                                             modest_heisenberg

It could be better that TC stops it before it retries to start it to use less resource on the machine. TBH I don't know how much of it is a problem but it seems not right somehow.

WDYT?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions