]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: checks: fix health check regression causing them to depend on declaration...
authorWilly Tarreau <w@1wt.eu>
Tue, 3 Dec 2013 10:11:34 +0000 (11:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 3 Dec 2013 10:20:20 +0000 (11:20 +0100)
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.

src/cfgparse.c

index 7087c65c3a260028cd9dd0135ce5a28d2d2679f2..e267de8c8330037d7b06d913a150ee3fe9367f46 100644 (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;