mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
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).
This commit is contained in:
parent
15f3910214
commit
33a08db932
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user