]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker: deserialize process list before read_cfg_in_discovery_mode
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 11 Oct 2024 17:39:12 +0000 (19:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:02:39 +0000 (22:02 +0200)
This patch is a part of series to reintroduce the program support in the new
master-worker architecture.

For the moment we keep the order of program and worker forks the same as before
the refactoring, as we need to be sure that this won't introduce regressions.
So, programs are forked before the new worker process.

Before the program's fork we already need deserialized processes list to find
the programs launched before reload and to stop them. Processes list saved
before the reload in HAPROXY_PROCESSES variable. It should be deserialized
before the first configuration read in discovery mode, because resetenv keyword
could be presented in the global section.

So, let's move mworker_env_to_proc_list() from mworker_create_master_cli() to
main(). We need to call it only after reload in master-worker mode, thus
HAPROXY_MWORKER_REEXEC and HAPROXY_PROCESSES should be still presented in the
re-executing process environment before the first configuration read.

src/haproxy.c
src/mworker.c

index 5ed6c7edb3054150017bac765d5ff488619fa677..b934850cf29762cb7eb625fd673b8b755e9e5b84 100644 (file)
@@ -3714,6 +3714,15 @@ int main(int argc, char **argv)
         */
        step_init_1();
 
+       /* deserialize processes list, if we do reload in master-worker mode */
+       if ((getenv("HAPROXY_MWORKER_REEXEC") != NULL)) {
+               if (mworker_env_to_proc_list() < 0) {
+                       ha_alert("Master failed to deserialize monitored processes list, "
+                                "it's a non-recoverable error, exiting.\n");
+                       exit(EXIT_FAILURE);
+               }
+       }
+
        /* parse conf in disovery mode and set modes from config */
        read_cfg_in_discovery_mode(argc, argv);
 
index 31374eafc1d069083b37f3147ee708d33b8d79e5..874bfd1f62b199e7f63fd8e42985415ad8220cf1 100644 (file)
@@ -845,11 +845,6 @@ void mworker_create_master_cli(void)
 {
        struct wordlist *it, *c;
 
-       /* get the info of the children in the env */
-       if (mworker_env_to_proc_list() < 0) {
-               exit(EXIT_FAILURE);
-       }
-
        if (!LIST_ISEMPTY(&mworker_cli_conf)) {
                char *path = NULL;