MINOR: dns: implement extra 'hold' timers.

This adds new "hold" timers : nx, refused, timeout, other. This timers
will be used to tell HAProxy to keep an erroneous response as valid for
the corresponding period. For now they're only configured, not enforced.
This commit is contained in:
Baptiste Assmann 2016-11-02 22:23:31 +01:00 committed by Willy Tarreau
parent 8b42848a44
commit 987e16d6f4
3 changed files with 27 additions and 5 deletions

View File

@ -11347,12 +11347,13 @@ nameserver <id> <ip>:<port>
hold <status> <period>
Defines <period> during which the last name resolution should be kept based
on last resolution <status>
<status> : last name resolution status. Only "valid" is accepted for now.
<status> : last name resolution status. Acceptable values are "nx",
"other", "refused", "timeout", "valid".
<period> : interval between two successive name resolution when the last
answer was in <status>. It follows the HAProxy time format.
<period> is in milliseconds by default.
Default value is 10s for "valid".
Default value is 10s for "valid" and 30s for others.
Note: since the name resolution is triggered by the health checks, a new
resolution is triggered after <period> modulo the <inter> parameter of
@ -11384,6 +11385,10 @@ timeout <event> <time>
nameserver dns2 10.0.0.2:53
resolve_retries 3
timeout retry 1s
hold other 30s
hold refused 30s
hold nx 30s
hold timeout 30s
hold valid 10s

View File

@ -148,6 +148,10 @@ struct dns_resolvers {
} timeout;
struct { /* time to hold current data when */
int valid; /* a response is valid */
int nx; /* a response doesn't exist */
int timeout; /* no answer was delivered */
int refused; /* dns server refused to answer */
int other; /* other dns response errors */
} hold;
struct task *t; /* timeout management */
struct list curr_resolution; /* current running resolutions */

View File

@ -2363,6 +2363,11 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
curr_resolvers->conf.line = linenum;
curr_resolvers->id = strdup(args[1]);
curr_resolvers->query_ids = EB_ROOT;
/* default hold period for nx, other, refuse and timeout is 30s */
curr_resolvers->hold.nx = 30000;
curr_resolvers->hold.other = 30000;
curr_resolvers->hold.refused = 30000;
curr_resolvers->hold.timeout = 30000;
/* default hold period for valid is 10s */
curr_resolvers->hold.valid = 10000;
curr_resolvers->timeout.retry = 1000;
@ -2462,11 +2467,19 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
if (strcmp(args[1], "valid") == 0)
if (strcmp(args[1], "nx") == 0)
curr_resolvers->hold.nx = time;
else if (strcmp(args[1], "other") == 0)
curr_resolvers->hold.other = time;
else if (strcmp(args[1], "refused") == 0)
curr_resolvers->hold.refused = time;
else if (strcmp(args[1], "timeout") == 0)
curr_resolvers->hold.timeout = time;
else if (strcmp(args[1], "valid") == 0)
curr_resolvers->hold.valid = time;
else {
Alert("parsing [%s:%d] : '%s' unknown <event>: '%s', expects 'valid'\n",
file, linenum, args[0], args[1]);
Alert("parsing [%s:%d] : '%s' unknown <event>: '%s', expects either 'nx', 'timeout', 'valid', or 'other'.\n",
file, linenum, args[0], args[1]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}