]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: dns: disabled servers through SRV records never recover
authorBaptiste Assmann <bedis9@gmail.com>
Tue, 4 Aug 2020 08:57:21 +0000 (10:57 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Aug 2020 19:48:23 +0000 (21:48 +0200)
A regression was introduced by 13a9232ebc63fdf357ffcf4fa7a1a5e77a1eac2b
when I added support for Additional section of the SRV responses..

Basically, when a server is managed through SRV records additional
section and it's disabled (because its associated Additional record has
disappeared), it never leaves its MAINT state and so never comes back to
production.
This patch updates the "snr_update_srv_status()" function to clear the
MAINT status when the server now has an IP address and also ensure this
function is called when parsing Additional records (and associating them
to new servers).

This can cause severe outage for people using HAProxy + consul (or any
other service registry) through DNS service discovery).

This should fix issue #793.
This should be backported to 2.2.

src/dns.c
src/server.c

index c97c7dc69b139be3db918daec64683c26295753b..333780293adc3c6dbd9f6682e1b05973e92bf146 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -648,6 +648,9 @@ static void dns_check_dns_response(struct dns_resolution *res)
                                if (msg)
                                        send_log(srv->proxy, LOG_NOTICE, "%s", msg);
 
+                               /* now we have an IP address associated to this server, we can update its status */
+                               snr_update_srv_status(srv, 0);
+
                                srv->svc_port = item->port;
                                srv->flags   &= ~SRV_F_MAPPORTS;
                                if ((srv->check.state & CHK_ST_CONFIGURED) &&
index 918294b2f4f98a054eeeecb0e5bf0a660f7e3c15..3f26104ccf61a27737501926b9191e57f901c328 100644 (file)
@@ -3733,6 +3733,12 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
 
        /* If resolution is NULL we're dealing with SRV records Additional records */
        if (resolution == NULL) {
+               /* since this server has an IP, it can go back in production */
+               if (has_no_ip == 0) {
+                       srv_clr_admin_flag(s, SRV_ADMF_RMAINT);
+                       return 1;
+               }
+
                if (s->next_admin & SRV_ADMF_RMAINT)
                        return 1;