mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-16 08:24:42 +00:00
BUG/MINOR: tcp-check: report the correct failed step in the status
The step number was reported by checking only last_started_step, which was not set in case of error during the initial connection phase, and caused "step 1" to be returned with an invalid check type (typically SEND). So now we first verify that a test was started before returning this. In addition to this, the indication of the test type was taken from current_step instead of last_started_step, so the error description was matching the next action instead of the one reported in the step ID. Thus we could get the confusing "step 1 (send)" report below : tcp-check connect tcp-check send foo In order to ease debugging, when the port number is known for a connect, it is indicated in the error report. Note that this only affects asynchronous error messages, synchronous ones are correct. This fix must be backported to 1.5.
This commit is contained in:
parent
ef953953e7
commit
213c678561
43
src/checks.c
43
src/checks.c
@ -586,6 +586,7 @@ static void chk_report_conn_err(struct connection *conn, int errno_bck, int expi
|
||||
struct check *check = conn->owner;
|
||||
const char *err_msg;
|
||||
struct chunk *chk;
|
||||
int step;
|
||||
|
||||
if (check->result != CHK_RES_UNKNOWN)
|
||||
return;
|
||||
@ -605,19 +606,27 @@ static void chk_report_conn_err(struct connection *conn, int errno_bck, int expi
|
||||
chk = get_trash_chunk();
|
||||
|
||||
if (check->type == PR_O2_TCPCHK_CHK) {
|
||||
chunk_printf(chk, " at step %d of tcp-check", tcpcheck_get_step_id(check->server));
|
||||
/* we were looking for a string */
|
||||
if (check->current_step && check->current_step->action == TCPCHK_ACT_CONNECT) {
|
||||
chunk_appendf(chk, " (connect)");
|
||||
}
|
||||
else if (check->current_step && check->current_step->action == TCPCHK_ACT_EXPECT) {
|
||||
if (check->current_step->string)
|
||||
chunk_appendf(chk, " (string '%s')", check->current_step->string);
|
||||
else if (check->current_step->expect_regex)
|
||||
chunk_appendf(chk, " (expect regex)");
|
||||
}
|
||||
else if (check->current_step && check->current_step->action == TCPCHK_ACT_SEND) {
|
||||
chunk_appendf(chk, " (send)");
|
||||
step = tcpcheck_get_step_id(check->server);
|
||||
if (!step)
|
||||
chunk_printf(chk, " at initial connection step of tcp-check");
|
||||
else {
|
||||
chunk_printf(chk, " at step %d of tcp-check", step);
|
||||
/* we were looking for a string */
|
||||
if (check->last_started_step && check->last_started_step->action == TCPCHK_ACT_CONNECT) {
|
||||
if (check->last_started_step->port)
|
||||
chunk_appendf(chk, " (connect port %d)" ,check->last_started_step->port);
|
||||
else
|
||||
chunk_appendf(chk, " (connect)");
|
||||
}
|
||||
else if (check->last_started_step && check->last_started_step->action == TCPCHK_ACT_EXPECT) {
|
||||
if (check->last_started_step->string)
|
||||
chunk_appendf(chk, " (string '%s')", check->last_started_step->string);
|
||||
else if (check->last_started_step->expect_regex)
|
||||
chunk_appendf(chk, " (expect regex)");
|
||||
}
|
||||
else if (check->last_started_step && check->last_started_step->action == TCPCHK_ACT_SEND) {
|
||||
chunk_appendf(chk, " (send)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2268,6 +2277,10 @@ static int tcpcheck_get_step_id(struct server *s)
|
||||
struct tcpcheck_rule *cur = NULL, *next = NULL;
|
||||
int i = 0;
|
||||
|
||||
/* not even started anything yet => step 0 = initial connect */
|
||||
if (!s->check.current_step)
|
||||
return 0;
|
||||
|
||||
cur = s->check.last_started_step;
|
||||
|
||||
/* no step => first step */
|
||||
@ -2337,9 +2350,9 @@ static void tcpcheck_main(struct connection *conn)
|
||||
goto out_end_tcpcheck;
|
||||
}
|
||||
|
||||
/* no step means first step
|
||||
* initialisation */
|
||||
/* no step means first step initialisation */
|
||||
if (check->current_step == NULL) {
|
||||
check->last_started_step = NULL;
|
||||
check->bo->p = check->bo->data;
|
||||
check->bo->o = 0;
|
||||
check->bi->p = check->bi->data;
|
||||
|
Loading…
Reference in New Issue
Block a user