BUG/MINOR: tcpcheck: Properly report error for http health-checks

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.
This commit is contained in:
Christopher Faulet 2026-05-04 07:52:41 +02:00
parent 4ef31cb5c2
commit e46090f424

View 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;