BUG/MINOR: config: allow to check HAPROXY_LOCALPEER in config

This fixes the commit d6ccd1738b
("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.
This commit is contained in:
Valentine Krasnobaeva 2024-11-21 17:49:24 +01:00 committed by Willy Tarreau
parent d253f30823
commit aa88d6ee37
2 changed files with 9 additions and 7 deletions

View File

@ -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 | | |

View File

@ -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);
}