From: Willy Tarreau Date: Wed, 11 Dec 2013 20:03:31 +0000 (+0100) Subject: MINOR: checks: add a PAUSED state for the checks X-Git-Tag: v1.5-dev20~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33a08db932ddc833fdb4e3f70f82e45075db5402;p=thirdparty%2Fhaproxy.git 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 252cb15b68..91b6f1be9e 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 98d4c678e2..78c46703d2 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -4721,6 +4721,7 @@ stats_error_parsing: 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 @@ out_uri_auth_compat: /* 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 9d906bdfb3..382bc59070 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 454795824f..25aa47185f 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++;