BUG: checks: fix server maintenance exit sequence
Recent commit 62c3be broke maintenance mode by fixing srv_is_usable().
Enabling a disabled server would not re-introduce it into the farm.
The reason is that in set_server_up(), the SRV_MAINTAIN flag is still
present when recounting the servers. The flag was removed late only to
adjust a log message. Keep a copy of the old flag instead and update
SRV_MAINTAIN earlier.
This fix must also be backported to 1.4 (but no release got the regression).
diff --git a/src/checks.c b/src/checks.c
index 7a9b56d..010fe6d 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -444,6 +444,7 @@
struct server *srv;
struct chunk msg;
int xferred;
+ unsigned int old_state = s->state;
if (s->state & SRV_MAINTAIN) {
s->health = s->rise;
@@ -461,6 +462,7 @@
s->last_change = now.tv_sec;
s->state |= SRV_RUNNING;
+ s->state &= ~SRV_MAINTAIN;
if (s->slowstart > 0) {
s->state |= SRV_WARMINGUP;
@@ -483,7 +485,7 @@
chunk_init(&msg, trash, sizeof(trash));
- if (s->state & SRV_MAINTAIN) {
+ if (old_state & SRV_MAINTAIN) {
chunk_printf(&msg,
"%sServer %s/%s is UP (leaving maintenance)", s->state & SRV_BACKUP ? "Backup " : "",
s->proxy->id, s->id);
@@ -505,8 +507,6 @@
if (! (srv->state & SRV_MAINTAIN))
/* Only notify tracking servers if they're not in maintenance. */
set_server_up(srv);
-
- s->state &= ~SRV_MAINTAIN;
}
if (s->health >= s->rise)