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

Testcontainers ryuk abandoned during build without testing using Gradle #25852

Closed
kdubb opened this issue May 29, 2022 · 13 comments · Fixed by #28702
Closed

Testcontainers ryuk abandoned during build without testing using Gradle #25852

kdubb opened this issue May 29, 2022 · 13 comments · Fixed by #28702
Assignees
Labels
area/gradle Gradle kind/bug Something isn't working
Milestone

Comments

@kdubb
Copy link
Contributor

kdubb commented May 29, 2022

Describe the bug

The ryuk container from the Testcontainers project is abandoned when building without running any tests.

We are experiencing this with Gradle, I cannot say wether this the same as for other build tools.

Also, we are using a multi-module Gradle project where we have many Quarkus micro-services under one parent project. If we build all the modules in one go, we get a ryuk container for each sub-module.

Expected behavior

Preferably ryuk containers are not started but at the very least they should be cleaned up after the build is done.

Actual behavior

Ryuk container(s) are abandoned and must be removed from docker manually.

How to Reproduce?

Run a build without testing in a Gradle single or multi-module project.

Example:

 ./gradlew build -Dquarkus.profile=prod -Dquarkus.container-image.build=true -x test -x integrationTest

Output of uname -a or ver

macOS 12

Output of java -version

Java 17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.4

Additional information

No response

@kdubb kdubb added the kind/bug Something isn't working label May 29, 2022
@quarkus-bot quarkus-bot bot added the area/gradle Gradle label May 29, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented May 29, 2022

/cc @glefloch, @quarkusio/devtools

@jskillin-idt
Copy link
Contributor

I am not a developer so take my suggestion here with healthy skepticism, but this is perhaps an issue with your Docker or test setup, as Ryuk is intended to self-destruct on its own once it observes the JVM closing.

@geoand
Copy link
Contributor

geoand commented Oct 19, 2022

Is this still an issue?

@kdubb
Copy link
Contributor Author

kdubb commented Oct 19, 2022

I will check. We had put a task in our Gradle project to kill all ryuk containers after completion; not pretty but it worked.

@kdubb
Copy link
Contributor Author

kdubb commented Oct 19, 2022

Screen Shot 2022-10-19 at 8 54 35 AM

@geoand
Copy link
Contributor

geoand commented Oct 19, 2022

Darn...

@kdubb
Copy link
Contributor Author

kdubb commented Oct 19, 2022

I've just realized those orphaned containers are specifically from our systemTest task/configuration. It uses a Gradle nested build (a GradleBuild task in main build.gradle.kts) to build the project with the correct profile and then starts all the services using Docker Compose to runs some e2e tests.

The orphaned ryuk containers are from when it builds some of the services in the nested build. If I run the same type build as the nested build from the command line it doesn't happen.

@kdubb
Copy link
Contributor Author

kdubb commented Oct 19, 2022

I did some more testing on this and it's the container build that causes the issue.

Running the following command orphans the ryuk containers:

./gradlew build -Dquarkus.container-image.build=true -x test

@kdubb
Copy link
Contributor Author

kdubb commented Oct 19, 2022

I'm trying to recreate a simple multi-module Gradle project that reproduces this behavior.

@kdubb
Copy link
Contributor Author

kdubb commented Oct 19, 2022

I've finally created a reproducer. It seems related to multi-module projects and building containers.

The first project, lib, is a java library and includes @QuarkusTests to test our common code that requires Quarkus extensions. For example, this includes common code that accesses Vault.

The second project, app, is a normal Quarkus application that includes lib to use the common code previously mentioned.

To reproduce the issue and get an orphaned ryuk container, run:

./gradlew clean build -Dquarkus.container-image.build=true

Running without tests, produces the same result:

./gradlew clean build -Dquarkus.container-image.build=true -x test

Notably, running a normal build with/without tests, using the following, will not orphan any containers:

./gradlew clean build

code-with-quarkus.zip

@geoand geoand self-assigned this Oct 20, 2022
@geoand
Copy link
Contributor

geoand commented Oct 20, 2022

Thanks for the thorough analysis!

I'll have a look

geoand added a commit to geoand/quarkus that referenced this issue Oct 20, 2022
Usually Ryuk containers started by TestContainers will be stopped,
but there are cases when after a build such containers are left
dangling.
With this change, we ensure that Ryuk is not started when all
we are doing is checking whether docker is available.

Fixes: quarkusio#25852
@geoand
Copy link
Contributor

geoand commented Oct 20, 2022

The reproducer was most helpful!

#28702 fixes the issue

gsmet added a commit that referenced this issue Oct 20, 2022
Ensure that Ryuk does not get started when simply checking for Docker
@quarkus-bot quarkus-bot bot added this to the 2.14 - main milestone Oct 20, 2022
Eng-Fouad pushed a commit to Eng-Fouad/quarkus that referenced this issue Oct 21, 2022
Usually Ryuk containers started by TestContainers will be stopped,
but there are cases when after a build such containers are left
dangling.
With this change, we ensure that Ryuk is not started when all
we are doing is checking whether docker is available.

Fixes: quarkusio#25852
tmihalac pushed a commit to tmihalac/quarkus that referenced this issue Oct 27, 2022
Usually Ryuk containers started by TestContainers will be stopped,
but there are cases when after a build such containers are left
dangling.
With this change, we ensure that Ryuk is not started when all
we are doing is checking whether docker is available.

Fixes: quarkusio#25852
@gsmet gsmet modified the milestones: 2.14.0.CR1, 2.13.4.Final Oct 31, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 31, 2022
Usually Ryuk containers started by TestContainers will be stopped,
but there are cases when after a build such containers are left
dangling.
With this change, we ensure that Ryuk is not started when all
we are doing is checking whether docker is available.

Fixes: quarkusio#25852
(cherry picked from commit 6c8eae8)
@jorsol
Copy link
Contributor

jorsol commented Nov 10, 2022

Just a comment here:

The ryuk container can be disabled by setting the env var TESTCONTAINERS_RYUK_DISABLED=true

https://www.testcontainers.org/features/configuration/#disabling-ryuk

zakkak pushed a commit to zakkak/quarkus that referenced this issue Nov 15, 2022
Usually Ryuk containers started by TestContainers will be stopped,
but there are cases when after a build such containers are left
dangling.
With this change, we ensure that Ryuk is not started when all
we are doing is checking whether docker is available.

Fixes: quarkusio#25852
(cherry picked from commit 6c8eae8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gradle Gradle kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants