From: Valentine Krasnobaeva Date: Thu, 21 Nov 2024 16:49:24 +0000 (+0100) Subject: BUG/MINOR: config: allow to check HAPROXY_LOCALPEER in config X-Git-Tag: v3.1-dev14~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa88d6ee372c8a1c85f1ec29159c082f00ab4726;p=thirdparty%2Fhaproxy.git BUG/MINOR: config: allow to check HAPROXY_LOCALPEER in config This fixes the commit d6ccd1738bae ("MINOR: startup: set HAPROXY_LOCALPEER only once"). HAPROXY_LOCALPEER could be checked in the configuration to set some servers settings or listeners. So, we need to set it just before we read the configuration at the second time. Let's mark HAPROXY_LOCALPEER as "usable" in the configuration in the related documentation chapter. This should not be backported, as related to the latest master-worker refactoring. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index b45fcf0731..7b7ded698e 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -998,7 +998,7 @@ modes: | HAPROXY_MWORKER | X | | | | | X | X | | HAPROXY_CLI | | | | | | | X | | HAPROXY_MASTER_CLI | | | | | | X | | - | HAPROXY_LOCALPEER | | | | | | | X | + | HAPROXY_LOCALPEER | | | X | | | | X | | HAPROXY_HTTP_LOG_FMT | | | X | | X | | | | HAPROXY_HTTP_CLF_LOG_FMT | | | X | | X | | | | HAPROXY_HTTPS_LOG_FMT | | | X | | X | | | diff --git a/src/haproxy.c b/src/haproxy.c index f551a2a179..7ba287a133 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3827,6 +3827,14 @@ int main(int argc, char **argv) } setenv("HAPROXY_MWORKER", "1", 1); } + + /* localpeer default value could be redefined via 'localpeer' keyword + * from the global section, which has already parsed in MODE_DISCOVERY by + * read_cfg_in_discovery_mode(). So, let's set HAPROXY_LOCALPEER explicitly + * here. + */ + setenv("HAPROXY_LOCALPEER", localpeer, 1); + non_global_section_parsed = 0; if (read_cfg() < 0) { list_for_each_entry_safe(cfg, cfg_tmp, &cfg_cfgfiles, list) { @@ -3839,12 +3847,6 @@ int main(int argc, char **argv) list_for_each_entry_safe(cfg, cfg_tmp, &cfg_cfgfiles, list) ha_free(&cfg->content); - /* localpeer could be redefined via 'localpeer' keyword from the - * global section, in master-worker mode it's parsed only by - * worker, so let set HAPROXY_LOCALPEER explicitly here - */ - if (localpeer != NULL) - setenv("HAPROXY_LOCALPEER", localpeer, 1); usermsgs_clr(NULL); }