BUG/MEDIUM: server/dns: prevent DOWN/UP flap upon resolution timeout or error
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 28 Jun 2024 07:41:56 +0000 (09:41 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Jul 2024 06:44:44 +0000 (08:44 +0200)
commita8740d10466cfc3102576f8627b17b6107e7edb0
treebba458898ca964375fdfc0388714c44c338c83b1
parentdd42e4233d2c6cc328e61ac0bf8f3375de1667e9
BUG/MEDIUM: server/dns: prevent DOWN/UP flap upon resolution timeout or error

This is a complementary patch to c16eba818 ("BUG/MEDIUM: server/dns:
preserve server's port upon resolution timeout or error").

Indeed, since c16eba818, the port is properly preserved, but unsetting
server's address this way results in server_atomic_sync() function
thinking that we're actually setting a new address and not unsetting
the previous one because addr family is != AF_UNSPEC.

Upon DNS timeout, this could be observed:

[WARNING]  (2588257) : Server http/s1 is going DOWN for maintenance (DNS timeout status). 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING]  (2588257) : Server http/s1 ('test1.localhost') is UP/READY (resolves again).

Notice that server timeouts and then immediately resolves again. Of course
in this case case the server's address was properly set to 0, meaning
that the server will not receive any traffic, but it is confusing and
could result in haproxy temporarily thinking that the server is actually
available while it's not.

To properly fix the issue and restore historical behavior, let's
explicitly set inetaddr's family to AF_UNSPEC after fetching original
server's address.

It should be backported in 3.0 with c16eba818.

(cherry picked from commit 80aba1d2844165d9c6929d31cc9c2fd2e92286ed)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/server.c