hazelcast-docker-swarm-discovery-spi icon indicating copy to clipboard operation
hazelcast-docker-swarm-discovery-spi copied to clipboard

dnsrr discovery method does not work when "healthcheck" used

Open mnoky opened this issue 4 years ago • 6 comments

Great project, I'm excited to get this working for a service I have deployed in a docker cluster! Currently testing 1.0-RC14 and I've hit the following snag:

The dnsrr discovery method does not work when a docker "healthcheck" is used. Reason being: during startup, the service name cannot be resolved. The name is not available until after the healthcheck succeeds and the service is up and running. Thus, it is a bit of a chicken-and-egg problem. The following exception is thrown at startup and the service cannot start (only relevant lines shown)

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.hazelcast.core.HazelcastInstance]: Factory method 'hazelcastInstance' threw exception; nested exception is com.hazelcast.config.ConfigurationException: Cannot create a new instance of MemberAddressProvider 'class org.bitsofinfo.hazelcast.spi.docker.swarm.dnsrr.DockerDNSRRMemberAddressProvider'
...
Caused by: com.hazelcast.config.ConfigurationException: Cannot create a new instance of MemberAddressProvider 'class org.bitsofinfo.hazelcast.spi.docker.swarm.dnsrr.DockerDNSRRMemberAddressProvider'
...
    at com.hazelcast.instance.DefaultNodeContext.newMemberAddressProviderInstance(DefaultNodeContext.java:94)
    ... 63 more
    Caused by: java.net.UnknownHostException: my_service: Name or service not known
...
    at org.bitsofinfo.hazelcast.spi.docker.swarm.dnsrr.DockerDNSRRMemberAddressProvider.resolveServiceName(DockerDNSRRMemberAddressProvider.java:130)

When I disable the healthcheck for my service, the dns resolution works right away and there are no problems.

Is it possible to delay the dns lookup in DockerDNSRRMemberAddressProvider? Or does it need to be available right away?

mnoky avatar Jul 30 '19 12:07 mnoky