From 33a08db932ddc833fdb4e3f70f82e45075db5402 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 11 Dec 2013 21:03:31 +0100 Subject: [PATCH] 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). --- include/types/checks.h | 1 + src/cfgparse.c | 2 ++ src/checks.c | 9 +++++---- src/dumpstats.c | 3 +++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/types/checks.h b/include/types/checks.h index 252cb15b6..91b6f1be9 100644 --- a/include/types/checks.h +++ b/include/types/checks.h @@ -38,6 +38,7 @@ enum chk_result { #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 98d4c678e..78c46703d 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -4721,6 +4721,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) 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 @@ int check_config_validity() /* 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 9d906bdfb..382bc5907 100644 --- a/src/checks.c +++ b/src/checks.c @@ -493,6 +493,7 @@ void set_server_up(struct check *check) { 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 @@ static struct task *process_chk(struct task *t) * 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 454795824..25aa47185 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -1555,6 +1555,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) 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 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) 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 @@ static int stats_process_http_post(struct stream_interface *si) 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++;