]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: init: also set the worker-id in file-less mode
authorWilly Tarreau <w@1wt.eu>
Fri, 25 Sep 2026 08:17:21 +0000 (10:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Sep 2026 14:24:48 +0000 (16:24 +0200)
The worker-id generation at boot, as done in commit 3639aac31f ("MINOR:
config: add a "worker-id" global keyword to identify the worker"), would
escape the file-less mode that is used with haterm and haload. There's
nothing dramatic in this, but it may end up being surprising with certain
corner-case configs that would want to exploit it (logging, header
contents etc), so better set it now for consistency between any worker
mode.

It was visible by running haterm:

    $ ./haterm -L :8000 -G "stats socket /tmp/sock1 level admin"

and issuing:

    $ socat - /tmp/sock1 <<< "show info"

which didn't show the Worker_id line before the fix. No backport is
needed.

src/haproxy.c

index 317855bd9152bf9ac48d91061258bbfb0d3fb4d7..e965aa584559d4de9d72a4015e90da8cb1f94525 100644 (file)
@@ -2218,6 +2218,12 @@ static void step_init_2(int argc, char** argv)
        }
        last_defproxy = NULL; /* This variable is not used after parsing. */
 
+       /* In fileless mode (haterm, haload, ...) it's the only place where
+        * we'll be able to initialize the worker id.
+        */
+       if (!master)
+               init_worker_id();
+
        if (global.tune.options & GTUNE_PURGE_DEFAULTS) {
                /* destroy unreferenced defaults proxies  */
                defaults_px_destroy_all_unref();