diff --git a/doc/management.txt b/doc/management.txt index b5e041a0b..751621c03 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -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 the total allocatable memory to 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 diff --git a/include/types/global.h b/include/types/global.h index 9f069ad25..a790e7439 100644 --- a/include/types/global.h +++ b/include/types/global.h @@ -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 diff --git a/src/haproxy.c b/src/haproxy.c index 4806c564d..b899c76e4 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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') diff --git a/src/server.c b/src/server.c index c351707bb..a1deae8e7 100644 --- a/src/server.c +++ b/src/server.c @@ -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)) {