]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: config: allow to check HAPROXY_LOCALPEER in config
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Thu, 21 Nov 2024 16:49:24 +0000 (17:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 21 Nov 2024 18:55:21 +0000 (19:55 +0100)
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.

doc/configuration.txt
src/haproxy.c

index b45fcf07316756f4aacb0ce825c44f60cb01d31b..7b7ded698e075b87e6ebc4e6e829e488a04ba57e 100644 (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  |     |     |
index f551a2a17997883521913f784719ee3594ba6e8d..7ba287a133a0af49fbead0226949b204d4e1ac71 100644 (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);
        }