]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: dns: improve DNS response parsing to use as many available records as possible
authorBaptiste <bedis9@gmail.com>
Mon, 26 Dec 2016 22:21:08 +0000 (23:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Mar 2017 10:54:51 +0000 (11:54 +0100)
commitfc725905443dffd08a335b2a71a4f370118797d5
tree2a8c81492d699e4c7aea7239da1a5a393e045bd8
parent203ec5a2b566bfd731538ad4ea21a849b79412ad
MINOR: dns: improve DNS response parsing to use as many available records as possible

A "weakness" exist in the first implementation of the parsing of the DNS
responses: HAProxy always choses the first IP available matching family
preference, or as a failover, the first IP.

It should be good enough, since most DNS servers do round robin on the
records they send back to clients.
That said, some servers does not do proper round robin, or we may be
unlucky too and deliver the same IP to all the servers sharing the same
hostname.

Let's take the simple configuration below:

  backend bk
    srv s1 www:80 check resolvers R
    srv s2 www:80 check resolvers R

The DNS server configured with 2 IPs for 'www'.
If you're unlucky, then HAProxy may apply the same IP to both servers.

Current patch improves this situation by weighting the decision
algorithm to ensure we'll prefer use first an IP found in the response
which is not already affected to any server.

The new algorithm does not guarantee that the chosen IP is healthy,
neither a fair distribution of IPs amongst the servers in the farm,
etc...
It only guarantees that if the DNS server returns many records for a
hostname and that this hostname is being resolved by multiple servers in
the same backend, then we'll use as many records as possible.
If a server fails, HAProxy won't pick up an other record from the
response.
src/dns.c