MINOR: checks: add a PAUSED state for the checks
Health checks can now be paused. This is the status they get when the
server is put into maintenance mode, which is more logical than relying
on the server's state at some places. It will be needed to allow agent
checks to run when health checks are disabled (currently not possible).
diff --git a/include/types/checks.h b/include/types/checks.h
index 252cb15..91b6f1b 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -38,6 +38,7 @@
#define CHK_ST_INPROGRESS 0x0001 /* a check is currently running */
#define CHK_ST_CONFIGURED 0x0002 /* this check is configured and may be enabled */
#define CHK_ST_ENABLED 0x0004 /* this check is currently administratively enabled */
+#define CHK_ST_PAUSED 0x0008 /* checks are paused because of maintenance (health only) */
/* check status */
enum {
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 98d4c67..78c4670 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -4721,6 +4721,7 @@
else if (!defsrv && !strcmp(args[cur_arg], "disabled")) {
newsrv->state |= SRV_MAINTAIN;
newsrv->state &= ~SRV_RUNNING;
+ newsrv->check.state |= CHK_ST_PAUSED;
newsrv->check.health = 0;
newsrv->agent.health = 0;
cur_arg += 1;
@@ -7038,6 +7039,7 @@
/* if the other server is forced disabled, we have to do the same here */
if (srv->state & SRV_MAINTAIN) {
newsrv->state |= SRV_MAINTAIN;
+ newsrv->check.state |= CHK_ST_PAUSED;
newsrv->state &= ~SRV_RUNNING;
newsrv->check.health = 0;
newsrv->agent.health = 0;
diff --git a/src/checks.c b/src/checks.c
index 9d906bd..382bc59 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -493,6 +493,7 @@
s->last_change = now.tv_sec;
s->state |= SRV_RUNNING;
s->state &= ~SRV_MAINTAIN;
+ s->check.state &= ~CHK_ST_PAUSED;
if (s->slowstart > 0) {
s->state |= SRV_WARMINGUP;
@@ -1506,10 +1507,10 @@
* stopped, the server should not be checked or the check
* is disabled.
*/
- if (!(s->check.state & CHK_ST_ENABLED) ||
- s->proxy->state == PR_STSTOPPED ||
- (s->state & SRV_MAINTAIN) ||
- !(check->state & CHK_ST_ENABLED))
+ if (!(check->state & CHK_ST_ENABLED) ||
+ !(s->check.state & CHK_ST_ENABLED) ||
+ (s->check.state & CHK_ST_PAUSED) ||
+ s->proxy->state == PR_STSTOPPED)
goto reschedule;
/* we'll initiate a new check */
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 4547958..25aa471 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -1555,6 +1555,7 @@
sv->check.health = sv->check.rise; /* up, but will fall down at first failure */
} else {
sv->state &= ~SRV_MAINTAIN;
+ sv->check.state &= ~CHK_ST_PAUSED;
set_server_down(&sv->check);
}
} else {
@@ -1618,6 +1619,7 @@
if (! (sv->state & SRV_MAINTAIN)) {
/* Not already in maintenance, we can change the server state */
sv->state |= SRV_MAINTAIN;
+ sv->check.state |= CHK_ST_PAUSED;
set_server_down(&sv->check);
}
@@ -4039,6 +4041,7 @@
if ((px->state != PR_STSTOPPED) && !(sv->state & SRV_MAINTAIN)) {
/* Not already in maintenance, we can change the server state */
sv->state |= SRV_MAINTAIN;
+ sv->check.state |= CHK_ST_PAUSED;
set_server_down(&sv->check);
altered_servers++;
total_servers++;