]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tcpcheck: Override external check if healthcheck section is set
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 Jun 2026 08:50:32 +0000 (10:50 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 Jun 2026 15:15:31 +0000 (17:15 +0200)
When an external check was configured at the proxy level, the healthcheck
section set on a server was not considered. The main reason was that the
check type of the server was always inherited for the proxy one.

To fix the issue, when a healthcheck section is set on a server line, the
check type for the server is forced to TCPCHK.

This patch must be backported to 3.4.

src/check.c
src/tcpcheck.c

index 1e166322aab573dcfc1a256b09058089fd9b497c..3864e7c771502ecdd048aafd8eeb3897a76cbbb2 100644 (file)
@@ -1802,7 +1802,7 @@ int init_srv_check(struct server *srv)
        if (!srv->do_check || !(srv->proxy->cap & PR_CAP_BE))
                goto out;
 
-       if ((srv->proxy->options2 & PR_O2_CHK_ANY) != PR_O2_TCPCHK_CHK)
+       if (!srv->check.type && (srv->proxy->options2 & PR_O2_CHK_ANY) != PR_O2_TCPCHK_CHK)
                goto init;
 
        check_type = srv->check.tcpcheck->rs->flags & TCPCHK_RULES_PROTO_CHK;
@@ -1945,7 +1945,7 @@ int init_srv_check(struct server *srv)
        }
 
   init:
-       err = init_check(&srv->check, srv->proxy->options2 & PR_O2_CHK_ANY);
+       err = init_check(&srv->check, srv->check.type ? srv->check.type : (srv->proxy->options2 & PR_O2_CHK_ANY));
        if (err) {
                ha_alert("config: %s '%s': unable to init check for server '%s' (%s).\n",
                         proxy_type_str(srv->proxy), srv->proxy->id, srv->id, err);
index 4d01f2f3b9b4554112edf51d625a842360cee0c5..1a8d8bf23d73b62c73db033eafd79136a32ea394 100644 (file)
@@ -4198,7 +4198,7 @@ int check_server_tcpcheck(struct server *srv)
                }
                srv->check.tcpcheck->rs = rs;
                srv->check.tcpcheck->flags = rs->conf.flags;
-
+               srv->check.type = PR_O2_TCPCHK_CHK;
                err_code = check_tcpcheck_ruleset(srv->proxy, rs);
        }