]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: checks: add a PAUSED state for the checks
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Dec 2013 20:03:31 +0000 (21:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Dec 2013 15:02:20 +0000 (16:02 +0100)
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
src/cfgparse.c
src/checks.c
src/dumpstats.c

index 252cb15b68b815844d348187cfd3f2bc5ad1592b..91b6f1be9e8d728f2fa5a9bcf6ccbbf66b30860c 100644 (file)
@@ -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 {
index 98d4c678e245ee8b1bd3ed14feb01042dd9cfd46..78c46703d246672408711224fb239e4323df8a13 100644 (file)
@@ -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;
index 9d906bdfb3b6663ce8679f64eef35486104df5dc..382bc590706223ac4be41da0a721d1682147cdbc 100644 (file)
@@ -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 */
index 454795824ff3e37bf53da45517145abb7ec5e3c5..25aa47185ff08635e10f05c8972c13cdd4d79ba0 100644 (file)
@@ -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++;