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

Add hint to allow retry after previous cached failure to find Docker environment #7533

Conversation

cbreezier
Copy link

Related to #6441

As per the linked issue, the original behaviour to disable retries to find a valid Docker environment was introduced in #456

However, this can lead to frustrating situations where it becomes impossible to rerun builds if testcontainers was ever accidentally run without a valid Docker environment present. This happens when a long-running daemon (eg, Gradle daemon) keeps the testcontainers classes around and the FAIL_FAST_ALWAYS flag is never cleared.

I don't think it's worth adding special commands to somehow reset this flag, and the original fix sounds like it addresses a valid problem.

If the maintainers think that it's worth it, it may be worth considering changing the FAIL_FAST_ALWAYS boolean to a timestamp and essentially cache the failure for a limited time, rather than forever. This at least provides an upper bound for the number of unnecessary pings to check a Docker environment.

My current PR simply adds a hint to users about why testcontainers is never retrying, and how to force a retry.

@cbreezier cbreezier requested a review from a team as a code owner September 15, 2023 10:58
@eddumelendez
Copy link
Member

Thanks for your contribution, @cbreezier. But, since this is mostly related to gradle users and a misconfigured container runtime we have decided to not merge this.

@rlconst
Copy link

rlconst commented Oct 17, 2024

@eddumelendez this is looks like middle-finger response. What exactly misconfigured in runtime and how to fix it or troubleshoot? Especially if it worked without changes for years and at some point broke.

@kiview
Copy link
Member

kiview commented Oct 21, 2024

@rlconst What kind of environment/setup do you have in which you face this issue? We routinely learned that such issues don't apply to users once the container runtime is correctly setup (and please note, only Docker CE and Docker Desktop are the container runtimes officially supported by Testcontainers, everything else is on a best-effort basis).

@rlconst
Copy link

rlconst commented Oct 25, 2024

@kiview if you give me instruction how to gather information I'll happily provide

Windows 11 23H2 (22631.4317), Dell XPS
Docker v4.12.0 WSL 2 based engine
Docker engine v20.10.17
Gradle 8.10.2
IntelliJIDEA 2024.2.3

Libs:
kotest-extensions-testcontainers:1.3.4
kotest:5.9.0
micronaut-test-kotest5:3.9.2
testcontainers:1.17.6 (I don't see testcontainer version specified explicitly, probably came from kotest or micronaut)
micronaut:3.10.4

I see docker itself is outdated. I'll update and report if the problem still persist in Docker 4.34.3.

The same setup works flawlessly inside k8s environment of github ce, so something with windows.

UPD: still failing on a new docker and became even worse: ./gradlew --stop don't help now

                java.lang.IllegalStateException: Mapped port can only be obtained after the container is started
                    at org.testcontainers.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:174)
                    at org.testcontainers.containers.ContainerState.getMappedPort(ContainerState.java:149)
                    at org.testcontainers.containers.PostgreSQLContainer.getJdbcUrl(PostgreSQLContainer.java:96)
                    at org.testcontainers.containers.JdbcDatabaseContainer.constructUrlForConnection(JdbcDatabaseContainer.java:276)
                    at org.testcontainers.containers.JdbcDatabaseContainer.createConnection(JdbcDatabaseContainer.java:236)
                    at org.testcontainers.jdbc.ContainerDatabaseDriver.connect(ContainerDatabaseDriver.java:130)
                    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
                    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
                    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
                    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
                    at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)

It helped to pull postgres and ruyk manually and disable containerd in docker settings. Still failing if build failed for some reason but --stop helps. Seems something don't cleanup properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants