MEDIUM: Do not mark a server as down if the agent is unavailable
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>
diff --git a/src/checks.c b/src/checks.c
index cffba02..4ab29e5 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -228,6 +228,12 @@
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 @@
{
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++;