Preserve DNS discovery backends when DNS fails and reloads

We are trying DNS recovery with TCP in HAPROXY 2.4.1, everything works supremely well other than an edge case.

Our cluster of HAPROXY config is written with API and reloads very often, for example 2000+ times a day.

HAPROXY queries the local DNS service configured within same server, when the DNS service fails, HAPROXY preserves the last valid responses it received until the next successful resolution (with help of hold valid and timeout resolve).

Now the problem is, when DNS service fails and HAPROXY reloads at the same time, servers configured on every backend goes out and this could cause a very big outage if happens in production.

Is there any option to preserve discovered backends across reloads and DNS failures? I tried init-addr last, but didn’t work.

Thanks for the great community support as always !

@lukastribus @Baptiste kindly any idea on this please?

init-addr last requires properly setting up server-state-file, meaning pointing to the file and before reloading, manually writing the the admin socket CLI output of show servers state into it.

Please read the documentation about init-addr last and server-state-file fully, it’s exactly the feature you need.

@lukastribus yes, we’ve set our systemd file to run the socketcli and write the servers state to the file.
The problem is, when we set the init-addr to last, haproxy just doesn’t start. It fails with no method found to resolve address. Is there any issue init-addr last and dnsdiscovery doesn’t go well?

Set it to

last,libc,none
1 Like