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

Quarkus fails to clean test containers on Podman 4.5.1 #33985

Closed
fedinskiy opened this issue Jun 12, 2023 · 12 comments
Closed

Quarkus fails to clean test containers on Podman 4.5.1 #33985

fedinskiy opened this issue Jun 12, 2023 · 12 comments
Labels
env/podman kind/bug Something isn't working

Comments

@fedinskiy
Copy link
Contributor

fedinskiy commented Jun 12, 2023

Describe the bug

I have an application, which uses Mariadb[1] database and depends on Quarkus to deploy the image in DevUI/tests. After I updated podman on my OS from 4.5.0 to 4.5.1, I noticed, that tests can not be run twice in a row. Investigation showed, that after the first run, the container for database stays running.
When Quarkus is not involved (Junit+testcontainers+same DB) everything works as expected.

[1] I was able to reproduce the bug with other DBs as well

Expected behavior

Any started containers should be stopped, same as for Docker and Podman 4.5.0

Actual behavior

Mariadb containers stays in running state

How to Reproduce?

  1. Clone: git clone [email protected]:fedinskiy/reproducer.git -b podman-451
  2. Run test: mvn clean verify -Dtest=QuarkusTest#testHelloEndpoint
  3. Check containers:
$ podman ps
CONTAINER ID  IMAGE                           COMMAND     CREATED         STATUS         PORTS                    NAMES
da4063230ad2  docker.io/library/mariadb:10.6  mariadbd    17 seconds ago  Up 17 seconds  0.0.0.0:42573->3306/tcp  gracious_austin
  1. Run test again: mvn clean verify -Dtest=QuarkusTest#testHelloEndpoint. Test hangs.

For comparison, non-Quarkus tests for the same DB work fine:

  1. mvn clean verify -Dtest=JunitTest
$ podman ps
CONTAINER ID  IMAGE                                COMMAND     CREATED         STATUS         PORTS                    NAMES
5f9a12104c86  docker.io/testcontainers/ryuk:0.3.4  /app        11 seconds ago  Up 11 seconds  0.0.0.0:44759->8080/tcp  testcontainers-ryuk-3ab6a3d0-010c-43db-86ca-1b265394cc9f
# ryuk runs for ~20 more seconds, afterwards it stops

3. mvn clean verify -Dtest=JunitTest succeeds

Output of uname -a or ver

4.18.0-425.19.2.el8_7.x86_64

Output of java -version

17.0.5, vendor: GraalVM Community

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.0.2.Final

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

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)

Additional information

$ podman version
Client:       Podman Engine
Version:      4.5.1
API Version:  4.5.1
Go Version:   go1.20.4
Built:        Fri May 26 19:58:48 2023
OS/Arch:      linux/amd64

See #33896 for similar problem

@gsmet
Copy link
Member

gsmet commented Jun 12, 2023

It does look like a Podman issue?

@fedinskiy
Copy link
Contributor Author

@gsmet for comparison, running non-Qurkus tests for the same DB succeeds, so test-containers + podman work fine without Quarkus. But it is definitely a podman-related issue.

@rsvoboda
Copy link
Member

@maxandersen pls check this, podman related.

When using just JUnit and TestContainers, no leftover container running.
But when using QuarkusTest, there is a leftover container

https://github.com/fedinskiy/reproducer/blob/podman-451/src/test/java/io/quarkus/qe/JunitTest.java
https://github.com/fedinskiy/reproducer/blob/podman-451/src/test/java/io/quarkus/qe/QuarkusTest.java

@maxandersen
Copy link
Member

Using podman in both cases?

@rsvoboda
Copy link
Member

yes

@maxandersen
Copy link
Member

what do you have in ~/.testcontainers.properties

if you see testcontainers.reuse.enable=true please try testcontainers.reuse.enable=false and run again.

if still see issue or that property gets changed we need to figure out why that is happening.

@fedinskiy
Copy link
Contributor Author

fedinskiy commented Jul 4, 2023

I tried switching testcontainers.reuse.enable to false

  1. The tests run successfully several times in a row, but there is a warning[1], about an issue with ryuk image
  2. I pull the required image manually: podman pull testcontainers/ryuk:0.3.4
  3. I start the test, it succeeds, testcontainers.reuse.enable is still false, but ruyk container is not stopped afterwards.
  4. If the test is started again, then testcontainers.reuse.enable is set to true right after the start
    It looks like podman messes with ryuk container behavior. My settings[2] require privileges for ryuk container, maybe podman messes with it?

[1]

2023-07-04 09:37:16,495 ERROR [com.git.doc.api.asy.ResultCallbackTemplate] (docker-java-stream--626058940) Error during callback: java.lang.NullPointerException: Cannot invoke "String.matches(String)" because the return value of "com.github.dockerjava.api.model.PullResponseItem.getStatus()" is null
	at com.github.dockerjava.api.command.PullImageResultCallback.checkForDockerSwarmResponse(PullImageResultCallback.java:48)
	at com.github.dockerjava.api.command.PullImageResultCallback.onNext(PullImageResultCallback.java:35)
	at org.testcontainers.images.LoggedPullImageResultCallback.onNext(LoggedPullImageResultCallback.java:48)
	at org.testcontainers.images.TimeLimitedLoggedPullImageResultCallback.onNext(TimeLimitedLoggedPullImageResultCallback.java:73)
	at org.testcontainers.images.TimeLimitedLoggedPullImageResultCallback.onNext(TimeLimitedLoggedPullImageResultCallback.java:24)
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrAsyncDockerCmdExec$1.onNext(AbstrAsyncDockerCmdExec.java:41)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder$JsonSink.accept(DefaultInvocationBuilder.java:315)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder$JsonSink.accept(DefaultInvocationBuilder.java:298)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:275)
	at java.base/java.lang.Thread.run(Thread.java:833)

2023-07-04 09:37:16,502 ERROR [🐳 .io/.6]] (build-30) Could not start container: org.testcontainers.containers.ContainerLaunchException: Container startup failed
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
	at org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78)
	at org.testcontainers.utility.RyukResourceReaper.register(RyukResourceReaper.java:68)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:423)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
	at io.quarkus.devservices.mariadb.deployment.MariaDBDevServicesProcessor$1.startDatabase(MariaDBDevServicesProcessor.java:67)
	at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:284)
	at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.launchDatabases(DevServicesDatasourceProcessor.java:136)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at java.base/java.lang.Thread.run(Thread.java:833)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=testcontainers/ryuk:0.3.4, imagePullPolicy=DefaultPullPolicy(), imageNameSubstitutor=org.testcontainers.utility.ImageNameSubstitutor$LogWrappedImageNameSubstitutor@48018513)
	at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1371)
	at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:651)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
	... 22 more
Caused by: java.lang.NullPointerException: Cannot invoke "String.matches(String)" because the return value of "com.github.dockerjava.api.model.PullResponseItem.getStatus()" is null
	at com.github.dockerjava.api.command.PullImageResultCallback.checkForDockerSwarmResponse(PullImageResultCallback.java:48)
	at com.github.dockerjava.api.command.PullImageResultCallback.onNext(PullImageResultCallback.java:35)
	at org.testcontainers.images.LoggedPullImageResultCallback.onNext(LoggedPullImageResultCallback.java:48)
	at org.testcontainers.images.TimeLimitedLoggedPullImageResultCallback.onNext(TimeLimitedLoggedPullImageResultCallback.java:73)
	at org.testcontainers.images.TimeLimitedLoggedPullImageResultCallback.onNext(TimeLimitedLoggedPullImageResultCallback.java:24)
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrAsyncDockerCmdExec$1.onNext(AbstrAsyncDockerCmdExec.java:41)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder$JsonSink.accept(DefaultInvocationBuilder.java:315)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder$JsonSink.accept(DefaultInvocationBuilder.java:298)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:275)
	at java.base/java.lang.Thread.run(Thread.java:833)

[2]

ryuk.container.privileged=true
docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
testcontainers.reuse.enable=false

@fedinskiy
Copy link
Contributor Author

@n1hility could you take a look?

@rsvoboda
Copy link
Member

@maxandersen @n1hility could you take a look?

@fedinskiy
Copy link
Contributor Author

fedinskiy commented Aug 28, 2023

It seems, that Podman 4.6.1 is not affected by this

UPD: on Podman 4.6.1 it doesn't block tests anymore, but containers are still not being stopped. This may cause temporary data to be persisted between runs

@n1hility
Copy link
Member

sure will take a look

@gsmet
Copy link
Member

gsmet commented Oct 2, 2024

From what I can see, the issue is solved in recent Podman as they reenabled the test there: quarkus-qe/quarkus-test-suite#1380 .

@gsmet gsmet closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
env/podman kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants