]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: tcpcheck: Properly report error for http health-checks
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 4 May 2026 05:52:41 +0000 (07:52 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 4 May 2026 14:33:56 +0000 (16:33 +0200)
When an error is reported on an expect rule for tcp and http health-checks,
a dedicated message is reported with details about the wrong match. However,
this was never performed for HTTP health-check because of the wrong test on
the check type.

In addition, when an error was reported on an "expect hdr" rule, a break
statement was missing. So the error message could be truncated (but never
emitted because of the issue above).

This patch should be backported to all stable versions.

src/tcpcheck.c

index 15ce41f3215d3623736a5e4888f2f011707f8c35..a500dbadffb8ed434996fa163159769bb3744c1e 100644 (file)
@@ -415,7 +415,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch
                                            int match, struct ist info)
 {
        struct sample *smp;
-       int is_empty;
+       int is_empty, check_type;
 
        /* Follows these step to produce the info message:
         *     1. if info field is already provided, copy it
@@ -433,6 +433,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch
                goto comment;
        }
 
+       check_type = (check->tcpcheck->rs->flags & TCPCHK_RULES_PROTO_CHK);
        is_empty = (IS_HTX_SC(check->sc) ? htx_is_empty(htxbuf(&check->bi)) : !b_data(&check->bi));
        if (is_empty) {
                TRACE_ERROR("empty response", CHK_EV_RX_DATA|CHK_EV_RX_ERR, check);
@@ -442,7 +443,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch
        }
 
        if (check->type == PR_O2_TCPCHK_CHK &&
-           (check->tcpcheck->rs->flags & TCPCHK_RULES_PROTO_CHK) != TCPCHK_RULES_TCP_CHK) {
+           check_type != TCPCHK_RULES_TCP_CHK && check_type !=TCPCHK_RULES_HTTP_CHK) {
                goto comment;
        }
 
@@ -479,6 +480,7 @@ static void tcpcheck_expect_onerror_message(struct buffer *msg, struct check *ch
                break;
        case TCPCHK_EXPECT_HTTP_HEADER:
                chunk_appendf(msg, " (header pattern) at step %d", tcpcheck_get_step_id(check, rule));
+               break;
        case TCPCHK_EXPECT_UNDEF:
                /* Should never happen. */
                return;