]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: init: add -dr to ignore server address resolution failures
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Nov 2016 20:03:16 +0000 (21:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Nov 2016 14:33:52 +0000 (15:33 +0100)
It is very common when validating a configuration out of production not to
have access to the same resolvers and to fail on server address resolution,
making it difficult to test a configuration. This option simply appends the
"none" method to the list of address resolution methods for all servers,
ensuring that even if the libc fails to resolve an address, the startup
sequence is not interrupted.

doc/management.txt
include/types/global.h
src/haproxy.c
src/server.c

index b5e041a0bd6fe154de529ab5231b5f4ded5507e0..751621c0392b034b189c1e240a6f21021b605738 100644 (file)
@@ -228,6 +228,14 @@ list of options is :
     generally be the "select" poller, which cannot be disabled and is limited
     to 1024 file descriptors.
 
+  -dr : ignore server address resolution failures. It is very common when
+    validating a configuration out of production not to have access to the same
+    resolvers and to fail on server address resolution, making it difficult to
+    test a configuration. This option simply appends the "none" method to the
+    list of address resolution methods for all servers, ensuring that even if
+    the libc fails to resolve an address, the startup sequence is not
+    interrupted.
+
   -m <limit> : limit the total allocatable memory to <limit> megabytes across
     all processes. This may cause some connection refusals or some slowdowns
     depending on the amount of memory needed for normal operations. This is
index 9f069ad25a67b7aca2f0c5543a7e644afc3dbc63..a790e743973ada7503a92ecdb337191539806162 100644 (file)
@@ -64,6 +64,7 @@
 #define GTUNE_USE_SPLICE         (1<<4)
 #define GTUNE_USE_GAI            (1<<5)
 #define GTUNE_USE_REUSEPORT      (1<<6)
+#define GTUNE_RESOLVE_DONTFAIL   (1<<7)
 
 /* Access level for a stats socket */
 #define ACCESS_LVL_NONE     0
index 4806c564deaec1ca9868edaf9cd1c876cce34c1a..b899c76e43df8569d357b78dd8defa1a954bb0af 100644 (file)
@@ -482,6 +482,7 @@ void usage(char *name)
 #if defined(SO_REUSEPORT)
                "        -dR disables SO_REUSEPORT usage\n"
 #endif
+               "        -dr ignores server address resolution failures\n"
                "        -dV disables SSL verify on servers side\n"
                "        -sf/-st [pid ]* finishes/terminates old pids.\n"
                "\n",
@@ -807,6 +808,8 @@ void init(int argc, char **argv)
                                arg_mode |= MODE_FOREGROUND;
                        else if (*flag == 'd' && flag[1] == 'M')
                                mem_poison_byte = flag[2] ? strtol(flag + 2, NULL, 0) : 'P';
+                       else if (*flag == 'd' && flag[1] == 'r')
+                               global.tune.options |= GTUNE_RESOLVE_DONTFAIL;
                        else if (*flag == 'd')
                                arg_mode |= MODE_DEBUG;
                        else if (*flag == 'c')
index c351707bbb4ab3f19513d8c94a50805d28d7e357..a1deae8e74bd79b9818aab82e1de16e98d954b93 100644 (file)
@@ -3249,6 +3249,13 @@ static int srv_iterate_initaddr(struct server *srv)
                srv_append_initaddr(&methods, SRV_IADDR_LIBC);
        }
 
+       /* "-dr" : always append "none" so that server addresses resolution
+        * failures are silently ignored, this is convenient to validate some
+        * configs out of their environment.
+        */
+       if (global.tune.options & GTUNE_RESOLVE_DONTFAIL)
+               srv_append_initaddr(&methods, SRV_IADDR_NONE);
+
        while (methods) {
                err_code = 0;
                switch (srv_get_next_initaddr(&methods)) {