Hi there, In attachment, a patch to fix a bug reported by Marcos on the ML during the summer. The bug is that "haproxy -c -f cfgfile" don't check for if a server's resolver section exist, despite "haproxy -f cfgfile" does it. The issue, is that init scripts are not able to detect a mis configuration and production can be impacted. (In Marocs case, the tool which builds the configuration forgot to set the resolvers section).
This patch aims at fixing this issue and now, if a resolvers section pointed by a server can't be found, then "haproxy -c -f cfgfile" will fail too: [ALERT] 247/111027 (28758) : config : backend 'bk_pouet', server 'bla': unable to find required resolvers 'dns' [ALERT] 247/111027 (28758) : Fatal errors found in configuration. Baptiste
From e618d06562a41d44c6023f2ea4f5d4a2ff306490 Mon Sep 17 00:00:00 2001 From: Baptiste Assmann <[email protected]> Date: Fri, 10 Aug 2018 10:56:38 +0200 Subject: [PATCH] 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 --- src/dns.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dns.c b/src/dns.c index 033fcc1..16a2c17 100644 --- a/src/dns.c +++ b/src/dns.c @@ -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); -- 2.7.4

