]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: checks: replace state DISABLED with CONFIGURED and ENABLED
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Dec 2013 19:11:55 +0000 (20:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Dec 2013 15:02:19 +0000 (16:02 +0100)
At the moment, health checks and agent checks are tied : no agent
check is emitted if no health check is enabled. Other parameters
are considered in the condition for letting checks run. It will
help us selectively enable checks (agent and regular checks) to be
know whether they're enabled/disabled and configured or not. Now
we can already emit an error when trying to enable an unconfigured
agent.

include/types/checks.h
src/cfgparse.c
src/checks.c
src/dumpstats.c

index b944cd38b3690815bb9607ef11240e5adce264fd..252cb15b68b815844d348187cfd3f2bc5ad1592b 100644 (file)
@@ -36,7 +36,8 @@ enum chk_result {
 
 /* flags used by check->state */
 #define CHK_ST_INPROGRESS       0x0001  /* a check is currently running */
-#define CHK_ST_DISABLED         0x0002  /* this check is currently administratively disabled */
+#define CHK_ST_CONFIGURED       0x0002  /* this check is configured and may be enabled */
+#define CHK_ST_ENABLED          0x0004  /* this check is currently administratively enabled */
 
 /* check status */
 enum {
index aa8bb90cf2d53e9af83b777c5c3eadf908314e91..b67594114be97301d8ea253e804fd29367e78829 100644 (file)
@@ -5123,6 +5123,7 @@ stats_error_parsing:
                                goto out;
                        }
 
+                       newsrv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
                        newsrv->state |= SRV_CHECKED;
                }
 
@@ -5145,6 +5146,7 @@ stats_error_parsing:
                                goto out;
                        }
 
+                       newsrv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
                        newsrv->state |= SRV_AGENT_CHECKED;
                }
 
index 321557705b294c5b86fa7186d24fc94da28b812a..49bb411955f876090d1a3d34abdf834910870d0e 100644 (file)
@@ -1165,7 +1165,7 @@ static void event_srv_chk_r(struct connection *conn)
                 * parameter of this function is the agent or check field
                 * of the server.
                 */
-               disabled = check->server->agent.state & CHK_ST_DISABLED;
+               disabled = !(check->server->agent.state & CHK_ST_ENABLED);
 
                if (strchr(check->bi->data, '%')) {
                        if (disabled)
@@ -1509,7 +1509,7 @@ static struct task *process_chk(struct task *t)
                if (!(s->state & SRV_CHECKED) ||
                    s->proxy->state == PR_STSTOPPED ||
                    (s->state & SRV_MAINTAIN) ||
-                   (check->state & CHK_ST_DISABLED))
+                   !(check->state & CHK_ST_ENABLED))
                        goto reschedule;
 
                /* we'll initiate a new check */
index ff8557a368e84ba7db608a480630b4c567d66653..350b11103525056a6bf23e74329d6ceccebbfc92 100644 (file)
@@ -1528,7 +1528,13 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                        if (!sv)
                                return 1;
 
-                       sv->agent.state &= ~CHK_ST_DISABLED;
+                       if (!(sv->agent.state & CHK_ST_CONFIGURED)) {
+                               appctx->ctx.cli.msg = "Agent was not configured on this server, cannot enable.\n";
+                               appctx->st0 = STAT_CLI_PRINT;
+                               return 1;
+                       }
+
+                       sv->agent.state |= CHK_ST_ENABLED;
                        return 1;
                }
                if (strcmp(args[1], "server") == 0) {
@@ -1599,7 +1605,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                        if (!sv)
                                return 1;
 
-                       sv->agent.state |= CHK_ST_DISABLED;
+                       sv->agent.state &= ~CHK_ST_ENABLED;
                        return 1;
                }
                else if (strcmp(args[1], "server") == 0) {