]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: server: make libc resolution failure non-fatal
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Nov 2016 18:19:22 +0000 (19:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Nov 2016 14:30:47 +0000 (15:30 +0100)
Now that we have "init-addr none", it becomes possible to recover on
libc resolver's failures. Thus it's preferable not to alert nor fail
at the moment the libc is called, and instead process the failure at
the end of the list. This allows "none" to be set after libc to
provide a smooth fallback in case of resolver issues.

src/server.c

index b99691430e7e381973993d1ac06e7245d066b9de..a5876d686fb7b32d73e217fa0050304f5c1e60f1 100644 (file)
@@ -3202,10 +3202,8 @@ int snr_resolution_error_cb(struct dns_resolution *resolution, int error_code)
 int srv_set_addr_via_libc(struct server *srv, int *err_code)
 {
        if (str2ip2(srv->hostname, &srv->addr, 1) == NULL) {
-               Alert("parsing [%s:%d] : 'server %s' : invalid address: '%s'\n",
-                     srv->conf.file, srv->conf.line, srv->id, srv->hostname);
                if (err_code)
-                       *err_code |= ERR_ALERT | ERR_FATAL;
+                       *err_code |= ERR_WARN;
                return 1;
        }
        return 0;
@@ -3260,6 +3258,10 @@ static int srv_iterate_initaddr(struct server *srv)
 
                case SRV_IADDR_NONE:
                        srv_set_admin_flag(srv, SRV_ADMF_RMAINT, NULL);
+                       if (return_code) {
+                               Warning("parsing [%s:%d] : 'server %s' : could not resolve address '%s', disabling server.\n",
+                                       srv->conf.file, srv->conf.line, srv->id, srv->hostname);
+                       }
                        return return_code;
 
                default: /* unhandled method */
@@ -3271,6 +3273,10 @@ static int srv_iterate_initaddr(struct server *srv)
                Alert("parsing [%s:%d] : 'server %s' : no method found to resolve address '%s'\n",
                      srv->conf.file, srv->conf.line, srv->id, srv->hostname);
        }
+       else {
+               Alert("parsing [%s:%d] : 'server %s' : could not resolve address '%s'.\n",
+                     srv->conf.file, srv->conf.line, srv->id, srv->hostname);
+       }
 
        return_code |= ERR_ALERT | ERR_FATAL;
        return return_code;