Hello,
I hope you can help, or at least guide me in the right direction. I have 4 host machines (docker containers). I am running some tests against this environment. But my consul behaves strangely.
consul.hello.com host: consul agent serveruser-service-1.hello.com: consul agent client + REST API + service discovery + health checkuser-service-2.hello.com: identical with user-service-1, same docker containerhello-service-1.hello.com: consul agent client + REST API that calls user-service
Everything works fine, when I start my docker stack the REST services register themselves properly:

user-service-1 details:
When hello-service asks for the URL of the user-service, consul returns with two URLs: user-service-1.hello.com and user-service-2.hello.com.
Then I stopped user-service-1.hello.com container completely, and consul recognized this event properly:
BUT, When hello-service asks for the URL of the user-service, consul still returns with user-service-1.hello.com despite this “machine” has been stopped completely. Not just the REST service in this host, but the host itself has been “turned off”:
user-service-1: no answer:
[root@consul.hello.com]# wget -q -S -O - https://user-service-1.hello.com:8443/actuator/health
^C
user-service-2: OK:
[root@consul.hello.com]# wget -q -S -O - https://user-service-2.hello.com:8443/actuator/health
HTTP/1.1 200
Content-Type: application/vnd.spring-boot.actuator.v3+json
Transfer-Encoding: chunked
Date: Tue, 12 Mar 2024 20:22:40 GMT
Connection: close
{"status":"UP"}
The REST services are Java Spring-Boot applications.
I have two questions:
-
As I see from Java when the
hello-serviceasks the consul foruser-serviceendpoint URL, it returns with 2 URLs and my Java app needs to do a random selection between the two (some kind of round-robin algorithm:). Can I configure consul somehow to return with only one URL based on a random selection?. -
Why
consoledoes not recognize that user-service-1 is dead? Consul only recognizes that the consul agent client is not running there but consul still offers the dead URL as well in the response. Why?




