]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: server: initialise agent.health in srv_settings_init()
authorSteven Honson <steven@honson.au>
Sat, 27 Jun 2026 12:27:30 +0000 (22:27 +1000)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 30 Jun 2026 15:39:07 +0000 (17:39 +0200)
commit7aec1e6d9ab2ccc11ce3c66610a8117cda2be094
treebb4ae8aca5b4514c3e44941719d2b8cd826d17b2
parentff6bb343f4a9c8dc38b2917ab1dd70785314b625
BUG/MEDIUM: server: initialise agent.health in srv_settings_init()

srv_settings_init() sets agent.rise but forgets agent.health, while
srv_settings_cpy() sets both. check.health is fixed up later when the
server's admin state is updated at startup, but nothing does the same
for agent.health.

This used to be harmless because servers were always set up through
srv_settings_cpy(). But since 49a619aca ("MEDIUM: proxy: no longer
allocate the default-server entry by default") the defsrv pointer is
NULL when a proxy has no "default-server" line, and srv_settings_cpy()
then falls back to srv_settings_init(). So a server whose agent-check is
declared entirely on its "server" line ends up with agent.health == 0,
which is below agent.rise.

The wrong value only bites when the server has to come back up. While it
stays up nobody notices agent.health is 0, but as soon as the regular
health check fails and recovers, agent.health is still 0 (below rise) and
check_notify_success() won't bring the server back up. The agent never
sends an explicit "up", which is the only thing that raises agent.health,
so the server stays down for good. Moving the agent settings to a
"default-server" line works around it.

Just initialise agent.health in srv_settings_init() like
srv_settings_cpy() already does.

This should be backported to 3.3 and 3.4.
src/server.c