dropwizard / dropwizard-discovery

Service discovery for Dropwizard using Curator
https://dropwizard.github.io/dropwizard-discovery/1.3.11/
Apache License 2.0
34 stars 15 forks source link

Add config option to provide IP matcher for CuratorAdvertiser to select correct local IP address #13

Open stantonk opened 8 years ago

stantonk commented 8 years ago

I'm not sure if this is the best way to solve this problem, but if you want to run a service locally and you use a VPN, the logic here:

https://github.com/dropwizard/dropwizard-discovery/blob/2c3f45b9a6612515762b0dcec8590f06aa27bff1/src/main/java/io/dropwizard/discovery/core/CuratorAdvertiser.java#L85

will sometimes pick the wrong local IP if you are connected to a VPN.

17:54:36.566 [main] INFO  i.d.discovery.core.CuratorAdvertiser - Using '192.168.225.102' as listenAddress from found addresses: [/192.168.225.102, /10.0.1.101]

Easiest solution I can think of is do have a config param for dropwizard-discovery to match those addresses returned by ServiceInstanceBuilder.getAllLocalIPs(); against a regex pattern like "^10\.0\.1\.\d+" or something like that.

jplock commented 8 years ago

You can specify an IP in the configuration. Does that work?

stantonk commented 8 years ago

@jplock it is a reasonable workaround for now, yes, but then the config can't be checked in and used by multiple developers who want to run integration tests. you'd have to manually modify the config each time you ran the tests on a different machine or on a different day (as IPs are dynamically allocated)