]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: dns: implement extra 'hold' timers.
authorBaptiste Assmann <bedis9@gmail.com>
Wed, 2 Nov 2016 21:23:31 +0000 (22:23 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Nov 2016 14:30:47 +0000 (15:30 +0100)
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.

doc/configuration.txt
include/types/dns.h
src/cfgparse.c

index b5127d6382ee3d9208e7ab692ad1cebba1c007ab..147a9fbe7f23a1f96c822ec19840491951984680 100644 (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
 
 
index b33924907748c4debd985713363fd67401188589..acff53a2ed0391f2305d4e005a218a1024893e3c 100644 (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 */
index 4923d8609478d1cc23339df43381602f67264304..356ae98107d69e8e56e32246179fb1f84c82925f 100644 (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;
                }