MEDIUM: server: make libc resolution failure non-fatal

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.
This commit is contained in:
Willy Tarreau 2016-11-07 19:19:22 +01:00
parent 37ebe1212b
commit 465b6e5463

View 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;