How to refresh HAProxy DNS caching?

Hi guys,

I don’t know how to properly give a “title” to this so let’s start.

Our current environment is moving towards automation (CI/CD, Packer, Google GCP, etc). Less and less human interaction.

With that being said, a VM/container would be redeployed exactly with the same name it had before. Example: payment01.

The current problem tho is that:

  • payment01 is deleted
  • HaProxy will stop sending requests to it. L7 healthy check.
  • payment01 is back online but via new VM or new container
  • HaProxy doesn’t it

HaProxy still expecting the payment01 that no longer exists. Different ID, DNS, etc.
To make it to send requests to the new VM/container, I have to reload it.

This looks like some sort of DNS “caching issue”. How can I possibly fix this??
Is there a refresh the DNS caching every 10seconds or something like that??

Any plan b, c, etc, are welcome.

Thanks guys.

Hi,
DNS names are resolved at start.
You can configure a resolver to take into account the update of the records without a reload: HAProxy version 2.2.7 - Configuration Manual

1 Like

Thank you @baptiste64
Now, I just need to find an example.

by example do you mean something like the tail of the haproxy.cfg looking like this?

backend blahblahblah
balance roundrobin
server logical_name_for_stats_real_port fqnd:real_port ssl verify required ca-file /etc/pki/tls/certs/fqdn.pem check

resolvers dnsresolver
nameserver dns1 ipaddressofdns1:53 (something like 192.168.1.23)
nameserver dns2 ipaddressofdns2:53 (something like 192.168.67.23)
resolve_retries 3
timeout retry 1s
hold nx 10s
hold valid 10s

@timdollimore thank you for the reply.
Yes, something like that. Since I asked this here, I found some examples but I got a weird problem since the resolvers are setting my backend servers to MAINT.
I have created this post HaProxy 2.2.9: Resolvers setting status to maintenance but so far no help.

Thanks a lot