BUG/MEDIUM: checks: fix health check regression causing them to depend on declaration order

Since commit 4a74143 (MEDIUM: Paramatise functions over the check of a
server), the check type is inherited from the current proxy's check type
at the moment where the server is declared instead of when reviewing
server configs. This causes an issue where a health check is disabled
when the server is declared before the checks. In fact the server will
inherit the last known check type declared before the "server" line :

  backend foo
        # this server is not checked at all
        server s1 1.1.1.1:80 check
        option tcpchk
        # this server is tcp-checked :
        server s2 1.1.1.2:80 check
        option httpchk
        # this server is http-checked :
        server s3 1.1.1.3:80 check

The fix consists in assigning the check type during the config review
phase where the config is stable. No backport is nedeed.
This commit is contained in:
Willy Tarreau 2013-12-03 11:11:34 +01:00
parent 9eba36b726
commit 2f075e98fb

View File

@ -4950,9 +4950,8 @@ stats_error_parsing:
goto out;
}
ret = init_check(&newsrv->check,
curproxy->options2 & PR_O2_CHK_ANY,
file, linenum);
/* note: check type will be set during the config review phase */
ret = init_check(&newsrv->check, 0, file, linenum);
if (ret) {
err_code |= ret;
goto out;
@ -6812,6 +6811,9 @@ out_uri_auth_compat:
cfgerr += ssl_sock_prepare_srv_ctx(newsrv, curproxy);
#endif /* USE_OPENSSL */
/* set the check type on the server */
newsrv->check.type = curproxy->options2 & PR_O2_CHK_ANY;
if (newsrv->trackit) {
struct proxy *px;
struct server *srv;