bitsofinfo / hazelcast-docker-swarm-discovery-spi

Docker Swarm based discovery strategy SPI for Hazelcast enabled applications
Apache License 2.0
39 stars 33 forks source link

Issue when using a docker healthcheck #11

Closed magno32 closed 6 years ago

magno32 commented 6 years ago

When adding a HEALTHCHECK directive to the docker image that tries to use discovery mechanism, there is a chicken and egg problem during service discovery.

We are using Spring managed hazelcast instances, so all of our configurations are done at startup. When using a docker healthcheck, the local task is in the starting state when discoverContainersViaCriteria runs. This causes an NPE when SwarmMemberAddressProvider.getBindAddress() is called, because myAddress inside SwarmDiscoveryUtil was never populated.

The issue is here:

https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/blob/a125c386ca9858d1193b58739088e623b0eb943f/src/main/java/org/bitsofinfo/hazelcast/discovery/docker/swarm/SwarmDiscoveryUtil.java#L389-L396

Here is my fix: c0be5de91f00729a3228d6630873573ed3cb3c0a but I don't know if it will fit in with all of the strategies you are using.

bitsofinfo commented 6 years ago

Hmm, thats probobly ok as I read it. Can you test this in a fork of your own using the travis config? If good then please submit a PR