BUG/MINOR: server-state: Avoid warning on 'file not found'

On a clean installation, users might want to use server-state-file and
the recommended zero-warning option. This caused a problem if
server-state-file was not found, as a warning was emited, causing
startup to fail.

This will allow users to specify nonexistent server-state-file at first,
and dump states to the file later.

Fixes #2190

CF: Technically speaking, this patch can be backported to all stable
    versions. But it is better to do so to 2.8 only for now.
This commit is contained in:
Marcos de Oliveira 2023-07-20 17:21:09 -03:00 committed by Christopher Faulet
parent 122a903b94
commit 462b54dee2

View File

@ -799,7 +799,10 @@ void apply_server_state(void)
errno = 0;
f = fopen(file, "r");
if (!f) {
ha_warning("config: Can't open global server state file '%s': %s\n", file, strerror(errno));
if (errno == ENOENT)
ha_notice("config: Can't open global server state file '%s': %s\n", file, strerror(errno));
else
ha_warning("config: Can't open global server state file '%s': %s\n", file, strerror(errno));
goto no_globalfile;
}
@ -871,8 +874,12 @@ void apply_server_state(void)
errno = 0;
f = fopen(file, "r");
if (!f) {
ha_warning("Proxy '%s': Can't open server state file '%s': %s.\n",
curproxy->id, file, strerror(errno));
if (errno == ENOENT)
ha_notice("Proxy '%s': Can't open server state file '%s': %s.\n",
curproxy->id, file, strerror(errno));
else
ha_warning("Proxy '%s': Can't open server state file '%s': %s.\n",
curproxy->id, file, strerror(errno));
continue; /* next proxy */
}