I’m trying to use the DNS SRV resolver feature with a local Consul agent and haproxy 1.8.14. I have a basic configuration working, but I’d like to get a specific behaviour when Consul is down, and I’m not sure what the right
hold settings are.
The behaviour I want is:
When the local Consul agent is working (DNS SRV queries return VALID answers), re-do the SRV query and update my
server-template configuration every 2 seconds.
When the local Consul agent is unavailable, leading to REFUSED or TIMEOUT (or maybe OTHER) errors:
- continue retrying the SRV request every 2 seconds, forever (until the queries start succeeding again)
- keep using the last valid response until queries start succeeding again, with no timeout
Here’s what I have so far, using very large retries and timeouts to simulate “forever”. I’ve done some testing and it seems to work (WEB-APP stayed available when the local consul agent was down for several minutes) but I’d love to get some feedback from someone who understands these settings better.
resolvers consul nameserver consul 127.0.0.1:53 accepted_payload_size 8192 timeout resolve 2s timeout retry 2s resolve_retries 100000 hold other 50000s hold refused 50000s hold timeout 50000s hold nx 5s hold valid 5s hold obsolete 5s listen WEB-APP bind 127.0.0.1:50002 mode http ... server-template web-app 50 _web-app._tcp.service.consul resolvers consul resolve-prefer ipv4 check inter 2s