]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: Do not mark a server as down if the agent is unavailable
authorSimon Horman <horms@verge.net.au>
Mon, 25 Nov 2013 01:46:37 +0000 (10:46 +0900)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Nov 2013 06:31:16 +0000 (07:31 +0100)
In the case where agent-port is used and the agent
check is a secondary check to not mark a server as down
if the agent becomes unavailable.

In this configuration the agent should only cause a server to be marked
as down if the agent returns "fail", "stopped" or "down".

Signed-off-by: Simon Horman <horms@verge.net.au>
doc/configuration.txt
src/checks.c

index 25fbf8f64c9aa34d8ecec78238b00d640fc09ec1..8094babaef3ca4ca03789fd58ccef466bd219933 100644 (file)
@@ -7700,6 +7700,10 @@ agent-check
 
     This currently has the same behaviour as "down".
 
+  Failure to connect to the agent is not considered an error as connectivity
+  is tested by the regular health check which is enabled by the "check"
+  parameter.
+
   Requires the ""agent-port" parameter to be set.
   See also the "agent-check" parameter.
 
index cffba0210b52e7651dbeb1cdfce373e3857ab94a..4ab29e501bee5fbe38b9d22a001c5f797bcfb16a 100644 (file)
@@ -228,6 +228,12 @@ static void set_server_check_status(struct check *check, short status, const cha
                tv_zero(&check->start);
        }
 
+       /* Failure to connect to the agent as a secondary check should not
+        * cause the server to be marked down. So only log status changes
+        * for HCHK_STATUS_* statuses */
+       if (check == &s->agent && check->status < HCHK_STATUS_L7TOUT)
+               return;
+
        if (s->proxy->options2 & PR_O2_LOGHCHKS &&
        (((check->health != 0) && (check->result & SRV_CHK_FAILED)) ||
            ((check->health != s->rise + s->fall - 1) && (check->result & SRV_CHK_PASSED)) ||
@@ -608,6 +614,15 @@ static void check_failed(struct check *check)
 {
        struct server *s = check->server;
 
+       /* The agent secondary check should only cause a server to be marked
+        * as down if check->status is HCHK_STATUS_L7STS, which indicates
+        * that the agent returned "fail", "stopped" or "down".
+        * The implication here is that failure to connect to the agent
+        * as a secondary check should not cause the server to be marked
+        * down. */
+       if (check == &s->agent && check->status != HCHK_STATUS_L7STS)
+               return;
+
        if (check->health > s->rise) {
                check->health--; /* still good */
                s->counters.failed_checks++;