MINOR: mworker: slow load status delivery if worker is starting

With refactored master-worker architecture master and worker processes parse
its parts of the configuration. Worker could have a huge configuration, so it
will take some time to load. As now HAPROXY_LOAD_SUCCESS is set to 1 only
after receiving the status READY from the new worker
cli_io_handler_show_loadstatus() may exit very fast by showing load status 0,
and in such case and mcli socket will be closed.

This already breaks some regression tests and can confuse some APIs. So, let's
slow down the load status delivery. If in the process list there is still some
process, which is loading (PROC_O_INIT). appctx task will sleep in this case for
50ms and then return 0. cli_io_handler_show_loadstatus() is called in loop, so
with such pacing, there is a high chance that the next time, when we enter in
its scope all processes will have the state READY. Like this master CLI
connection socket won't be closed until the loading of the new worker is really
finished, thus the reload status and logs (Success=1/0) will be shown in
synchronious way.
This commit is contained in:
Valentine Krasnobaeva 2024-10-15 10:45:35 +02:00 committed by Willy Tarreau
parent 5f16453082
commit d766677d92

View File

@ -748,11 +748,22 @@ static int cli_parse_reload(char **args, char *payload, struct appctx *appctx, v
* If the startup-logs is available, dump it. */
static int cli_io_handler_show_loadstatus(struct appctx *appctx)
{
struct mworker_proc *proc;
char *env;
if (!cli_has_level(appctx, ACCESS_LVL_OPER))
return 1;
/* if the worker is still in the process of starting, we have to
* wait a little bit before trying again to get a final status.
*/
list_for_each_entry(proc, &proc_list, list) {
if (proc->options & PROC_O_INIT) {
appctx->t->expire = tick_add(now_ms, 50);
return 0;
}
}
env = getenv("HAPROXY_LOAD_SUCCESS");
if (!env)
return 1;