BUG/MINOR: dns: check and link servers' resolvers right after config parsing

On the Mailing list, Marcos Moreno reported that haproxy configuration
validation (through "haproxy -c cfgfile") does not detect when a
resolvers section does not exist for a server.
That said, this checking is done after HAProxy has started up.

The problem is that this can create production issue, since init
script can't detect the problem before starting / reloading HAProxy.

To fix this issue, this patch registers the function which validates DNS
configuration validity and run it right after configuration parsing is
finished (through cfg_register_postparser()).
Thanks to it, now "haproxy -c cfgfile" will fail when a server
points to a non-existing resolvers section (or any other validation made
by the function above).

Backport status: 1.8
This commit is contained in:
Baptiste Assmann 2018-08-10 10:56:38 +02:00 committed by Willy Tarreau
parent 54620523e2
commit 044fd5bc2c

View File

@ -19,6 +19,7 @@
#include <sys/types.h>
#include <common/cfgparse.h>
#include <common/errors.h>
#include <common/time.h>
#include <common/ticks.h>
@ -2056,7 +2057,7 @@ static void __dns_init(void)
dns_answer_item_pool = create_pool("dns_answer_item", sizeof(struct dns_answer_item), MEM_F_SHARED);
dns_resolution_pool = create_pool("dns_resolution", sizeof(struct dns_resolution), MEM_F_SHARED);
hap_register_post_check(dns_finalize_config);
cfg_register_postparser("dns runtime resolver", dns_finalize_config);
hap_register_post_deinit(dns_deinit);
cli_register_kw(&cli_kws);