]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: checks: Properly handle email alerts in trace messages
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Jun 2022 07:12:58 +0000 (09:12 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Jun 2022 13:28:38 +0000 (15:28 +0200)
There is no server for email alerts. So the trace messages must be adapted
to handle this case. Information related to the server are now skipped for
email alerts and "[EMAIL]" prefix is used.

This patch must be backported as far as 2.4.

src/check.c

index f33e572fa4a42712e1490b32291f61946d3b1688..f717d09f3d0396164502a95675bcae0608cc2a90 100644 (file)
@@ -189,14 +189,18 @@ static void check_trace(enum trace_level level, uint64_t mask,
        if (!check || src->verbosity < CHK_VERB_CLEAN)
                return;
 
-       chunk_appendf(&trace_buf, " : [%c] SRV=%s",
-                     ((check->type == PR_O2_EXT_CHK) ? 'E' : (check->state & CHK_ST_AGENT ? 'A' : 'H')),
-                     srv->id);
-
-       chunk_appendf(&trace_buf, " status=%d/%d %s",
-                     (check->health >= check->rise) ? check->health - check->rise + 1 : check->health,
-                     (check->health >= check->rise) ? check->fall : check->rise,
-                     (check->health >= check->rise) ? (srv->uweight ? "UP" : "DRAIN") : "DOWN");
+       if (srv) {
+               chunk_appendf(&trace_buf, " : [%c] SRV=%s",
+                             ((check->type == PR_O2_EXT_CHK) ? 'E' : (check->state & CHK_ST_AGENT ? 'A' : 'H')),
+                             srv->id);
+
+               chunk_appendf(&trace_buf, " status=%d/%d %s",
+                             (check->health >= check->rise) ? check->health - check->rise + 1 : check->health,
+                             (check->health >= check->rise) ? check->fall : check->rise,
+                             (check->health >= check->rise) ? (srv->uweight ? "UP" : "DRAIN") : "DOWN");
+       }
+       else
+               chunk_appendf(&trace_buf, " : [EMAIL]");
 
        switch (check->result) {
        case CHK_RES_NEUTRAL: res = "-";     break;