quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Elasticsearch container with dev services does not shut down #38687

Closed m-stramel closed 6 months ago

m-stramel commented 8 months ago

Describe the bug

The elasticsearch container created with dev services does not shut down once the lifecycle of the process has stopped

Expected behavior

The elasticsearch container properly shuts down after the process has completed

Actual behavior

The elasticsearch container does not shut down when expected to

How to Reproduce?

elasticsearch-container-reproducer.zip

Output of uname -a or ver

No response

Output of java -version

build 17.0.7+0

Quarkus version or git rev

3.7.1, 3.7.2

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

No response

Additional information

Workaround: Include quarkus.elasticsearch.devservices.reuse=false in your application.properties file

Zulip conversation: https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/Elasticsearch.20docker.20container.20does.20not.20shut.20down

quarkus-bot[bot] commented 8 months ago

You added a link to a Zulip discussion, please make sure the description of the issue is comprehensive and doesn't require accessing Zulip

This message is automatically generated by a bot.

quarkus-bot[bot] commented 8 months ago

/cc @geoand (devservices), @gsmet (elasticsearch), @loicmathieu (elasticsearch), @stuartwdouglas (devservices), @yrodiere (elasticsearch)

yrodiere commented 8 months ago

Thanks for reporting, and for the reproducer!

Unfortunately, with your reproducer, and if I remove my ~/.testcontainers.properties file, the Elasticsearch container does get stopped after a run.

I even get that in logs:

2024-02-09 12:20:54,500 WARN  [tc.doc.io/.9.1] (build-11) Reuse was requested but the environment does not support the reuse of containers
To enable reuse of containers, you must set 'testcontainers.reuse.enable=true' in a file located at /home/yrodiere/.testcontainers.properties

(Note I did encounter a bug, #38706, but that's not the same thing)

So... I'm afraid I'll need more context.

How do you run the reproducer?

What logs do you see when you execute your reproducer?

What does your .testcontainers.properties file look like?

What's your OS?

What version of podman or docker do you have installed?

m-stramel commented 8 months ago

I only experienced this behavior when running the tests as you explained in #38706

yrodiere commented 8 months ago

Ok, then I can't reproduce this.

So:

What logs do you see when you execute your reproducer?

What does your .testcontainers.properties file look like?

What's your OS?

What version of podman or docker do you have installed?

m-stramel commented 8 months ago

Within my IDE i am right clicking the class name -> run test

What logs do you see when you execute your reproducer?

2024-02-21 10:42:33,634 INFO  [org.tes.doc.DockerClientProviderStrategy] (build-58) Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
2024-02-21 10:42:34,267 INFO  [org.tes.doc.DockerClientProviderStrategy] (build-58) Found Docker environment with local Unix socket (unix:///var/run/docker.sock)
2024-02-21 10:42:34,271 INFO  [org.tes.DockerClientFactory] (build-58) Docker host IP address is localhost
2024-02-21 10:42:34,307 INFO  [org.tes.DockerClientFactory] (build-58) Connected to docker: 
  Server Version: 20.10.12
  API Version: 1.41
  Operating System: Docker Desktop
  Total Memory: 7836 MB
2024-02-21 10:42:34,318 INFO  [org.tes.ima.PullPolicy] (build-58) Image pull policy will be performed by: DefaultPullPolicy()
2024-02-21 10:42:34,319 INFO  [org.tes.uti.ImageNameSubstitutor] (build-58) Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
2024-02-21 10:42:34,324 INFO  [org.tes.DockerClientFactory] (build-58) Checking the system...
2024-02-21 10:42:34,325 INFO  [org.tes.DockerClientFactory] (build-58) ✔︎ Docker server version should be at least 1.6.0
2024-02-21 10:42:34,456 INFO  [tc.doc.io/.9.1] (build-58) Creating container for image: docker.io/elastic/elasticsearch:8.9.1
2024-02-21 10:42:35,310 INFO  [org.tes.uti.RegistryAuthLocator] (build-58) Credential helper/store (docker-credential-desktop) does not have credentials for docker.io
2024-02-21 10:42:35,321 INFO  [tc.tes.6.0] (build-58) Creating container for image: testcontainers/ryuk:0.6.0
2024-02-21 10:42:35,349 INFO  [org.tes.uti.RegistryAuthLocator] (build-58) Credential helper/store (docker-credential-desktop) does not have credentials for https://index.docker.io/v1/
2024-02-21 10:42:35,910 INFO  [tc.tes.6.0] (build-58) Container testcontainers/ryuk:0.6.0 is starting: 16d5f44100301f4ff0c88bd640b4b60d930aabc4ca8b7f2527ccb4c08fb09fba
2024-02-21 10:42:37,250 INFO  [tc.tes.6.0] (build-58) Container testcontainers/ryuk:0.6.0 started in PT1.928744S
2024-02-21 10:42:38,033 INFO  [tc.doc.io/.9.1] (build-58) Container docker.io/elastic/elasticsearch:8.9.1 is starting: e1e4d7705897df5a709258f0958c010fa5c2cca9bafbd6318816efd5c35f9bc5
2024-02-21 10:42:50,040 INFO  [tc.doc.io/.9.1] (build-58) Container docker.io/elastic/elasticsearch:8.9.1 started in PT15.573875S
2024-02-21 10:42:50,087 WARN  [org.tes.ela.ElasticsearchContainer] (build-58) CA cert under /usr/share/elasticsearch/config/certs/http_ca.crt not found.
2024-02-21 10:42:50,095 INFO  [io.qua.ela.res.com.dep.DevServicesElasticsearchProcessor] (build-58) Dev Services for Elasticsearch started. Other Quarkus applications in dev mode will find the server automatically. For Quarkus applications in production mode, you can connect to this by configuring your application to use localhost:49770
2024-02-21 10:42:51,100 INFO  [io.quarkus] (main) elasticsearch-container-reproducer 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.7.2) started in 20.209s. 
2024-02-21 10:42:51,118 INFO  [io.quarkus] (main) Profile test activated. 
2024-02-21 10:42:51,119 INFO  [io.quarkus] (main) Installed features: [cdi, elasticsearch-java-client, elasticsearch-rest-client]
2024-02-21 10:42:51,624 INFO  [io.quarkus] (main) elasticsearch-container-reproducer stopped in 0.018s

What does your .testcontainers.properties file look like? I don't believe I have one. where would it be located at?

What's your OS? macOS Monterey

What version of podman or docker do you have installed? Docker version 20.10.12, build e91ed57

yrodiere commented 8 months ago

Is that the whole log? I don't see the warning I mentioned earlier about reuse needing to be enabled explicitly, that's suspicious.

Also:

2024-02-21 10:42:33,634 INFO [org.tes.doc.DockerClientProviderStrategy] (build-58) Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first

This looks like you do have a ~/.testcontainers.properties file.

where would it be located at?

See the docs: https://java.testcontainers.org/features/configuration/#configuration-locations

yrodiere commented 7 months ago

Hello @m-stramel , kind reminder that we don't have enough information to investigate this problem (can't reproduce it, seemingly incomplete logs).

geoand commented 6 months ago

Closing for lack of feedback