]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server/add: ensure minconn/maxconn consistency when adding server
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 8 Feb 2023 10:55:08 +0000 (11:55 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 8 Feb 2023 13:48:21 +0000 (14:48 +0100)
When a new server was added through the cli using "server add" command,
the maxconn/minconn consistency check historically implemented in
check_config_validity() for static servers was missing.

As a result, when adding a server with the maxconn parameter without the
minconn set, the server was unable to handle any connection because
srv_dynamic_maxconn() would always return 0.

Consider the following reproducer:

    |  global
    |    stats socket /tmp/ha.sock mode 660 level admin expose-fd listeners
    |
    |  defaults
    |  timeout client 5s
    |  timeout server 5s
    |  timeout connect 5s
    |
    |  frontend test
    |    mode http
    |    bind *:8081
    |    use_backend farm
    |
    |  listen dummyok
    |    bind localhost:18999
    |    mode http
    |    http-request return status 200 hdr test "ok"
    |
    |  backend farm
    |    mode http

Start haproxy and perform the following :

  echo "add server farm/t1 127.0.0.1:18999 maxconn 100" | nc -U /tmp/ha.sock
  echo "enable server farm/t1" | nc -U /tmp/ha.sock

  curl localhost:8081 # -> 503 after 5s connect timeout

Thanks to ("MINOR: cfgparse/server: move (min/max)conn postparsing logic into
dedicated function"), we are now able to perform the consistency check after
the new dynamic server has been parsed.
This is enough to fix the issue documented here that was reported by
Thomas Pedoussaut on the ML.

This commit depends on:
 - ("MINOR: cfgparse/server: move (min/max)conn postparsing logic into
     dedicated function")

It must be backported to 2.6 and 2.7

src/server.c

index 0ad51b3aba5758c5537104fd8e71174a615ef9f2..6e9d5113fed0ae407a1e47e7549af11c6e42d9e5 100644 (file)
@@ -4830,6 +4830,9 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
                goto out;
        }
 
+       /* ensure minconn/maxconn consistency */
+       srv_minmax_conn_apply(srv);
+
        if (srv->use_ssl == 1 || (srv->proxy->options & PR_O_TCPCHK_SSL) ||
            srv->check.use_ssl == 1) {
                if (xprt_get(XPRT_SSL) && xprt_get(XPRT_SSL)->prepare_srv) {