]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: check define check-reuse-pool server keyword
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 27 Mar 2025 14:09:52 +0000 (15:09 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 2 Apr 2025 12:57:40 +0000 (14:57 +0200)
Define a new server keyword check-reuse-pool, and its counterpart with a
"no" prefix. For the moment, only parsing is implemented. The real
behavior adjustment will be implemented in the next patch.

doc/configuration.txt
include/haproxy/check-t.h
src/check.c

index 156130282025419b770877270b8e914ac3c22159..b1219b52997ae581f526eba9b222075de7d06c65 100644 (file)
@@ -18203,6 +18203,22 @@ check
         tcp-check connect
         server s1 192.168.0.1:443 ssl check
 
+check-reuse-pool
+  May be used in the following contexts: tcp, http
+
+  This option permits checks to reuse idle connections if available instead of
+  opening a dedicated one. The connection is reinserted in the pool on check
+  completion. The main objective is to limit the number of connections opening
+  and closure on a specific server.
+
+  Note that for configuration simplicity, this option is silently ignored if
+  any specific check connect option is defined, either on the server line or
+  via a custom tcp-check connect rule.
+
+  If checks are activated for a reverse HTTP server, this option is mandatory
+  for checks to succeed, as by definition these servers do not have the ability
+  to initiate connection.
+
 check-send-proxy
   May be used in the following contexts: tcp, http
 
@@ -18702,6 +18718,12 @@ no-check
   It may also be used as "default-server" setting to reset any previous
   "default-server" "check" setting.
 
+no-check-reuse-pool
+  May be used in the following contexts: tcp, http
+
+  This option reverts any previous "check-reuse-pool" possibly inherited from a
+  "default-server". Any checks will be conducted on its dedicated connection.
+
 no-check-ssl
   May be used in the following contexts: tcp, http, log
 
index eb080a93a7041aa36fc41a3fcc2371368f121a0d..24cee86e930d189a1bef2423b2905f47b12dd8ae 100644 (file)
@@ -172,6 +172,7 @@ struct check {
        char desc[HCHK_DESC_LEN];               /* health check description */
        signed char use_ssl;                    /* use SSL for health checks (1: on, 0: server mode, -1: off) */
        int send_proxy;                         /* send a PROXY protocol header with checks */
+       int reuse_pool;                         /* try to reuse idle connections */
        struct tcpcheck_rules *tcpcheck_rules;  /* tcp-check send / expect rules */
        struct tcpcheck_rule *current_step;     /* current step when using tcpcheck */
        int inter, fastinter, downinter;        /* checks: time in milliseconds */
index e46fc654b14ae54960a5ec709306013d33a45534..52a55921f196e6fb8585cb3a20978fb3544494e0 100644 (file)
@@ -2345,6 +2345,15 @@ static int srv_parse_no_check(char **args, int *cur_arg, struct proxy *curpx, st
        return 0;
 }
 
+/* Parse the "no-check-reuse-pool" server keyword */
+static int srv_parse_no_check_reuse_pool(char **args, int *cur_arg,
+                                         struct proxy *curpx, struct server *srv,
+                                         char **errmsg)
+{
+       srv->check.reuse_pool = 0;
+       return 0;
+}
+
 /* Parse the "no-check-send-proxy" server keyword */
 static int srv_parse_no_check_send_proxy(char **args, int *cur_arg, struct proxy *curpx, struct server *srv,
                                         char **errmsg)
@@ -2377,6 +2386,15 @@ static int srv_parse_check_proto(char **args, int *cur_arg,
        goto out;
 }
 
+/* Parse the "check-reuse-pool" server keyword */
+static int srv_parse_check_reuse_pool(char **args, int *cur_arg,
+                                      struct proxy *curpx, struct server *srv,
+                                      char **errmsg)
+{
+       srv->check.reuse_pool = 1;
+       return 0;
+}
+
 
 /* Parse the "rise" server keyword */
 static int srv_parse_check_rise(char **args, int *cur_arg, struct proxy *curpx, struct server *srv,
@@ -2645,10 +2663,12 @@ static struct srv_kw_list srv_kws = { "CHK", { }, {
        { "agent-send",          srv_parse_agent_send,          1,  1,  1 }, /* Set string to send to agent. */
        { "check",               srv_parse_check,               0,  1,  1 }, /* Enable health checks */
        { "check-proto",         srv_parse_check_proto,         1,  1,  1 }, /* Set the mux protocol for health checks  */
+       { "check-reuse-pool",    srv_parse_check_reuse_pool,    0,  1,  1 }, /* Allows to reuse idle connections for checks */
        { "check-send-proxy",    srv_parse_check_send_proxy,    0,  1,  1 }, /* Enable PROXY protocol for health checks */
        { "check-via-socks4",    srv_parse_check_via_socks4,    0,  1,  1 }, /* Enable socks4 proxy for health checks */
        { "no-agent-check",      srv_parse_no_agent_check,      0,  1,  0 }, /* Do not enable any auxiliary agent check */
        { "no-check",            srv_parse_no_check,            0,  1,  0 }, /* Disable health checks */
+       { "no-check-reuse-pool", srv_parse_no_check_reuse_pool, 0,  1,  0 }, /* Disable PROXY protocol for health checks */
        { "no-check-send-proxy", srv_parse_no_check_send_proxy, 0,  1,  0 }, /* Disable PROXY protocol for health checks */
        { "rise",                srv_parse_check_rise,          1,  1,  1 }, /* Set rise value for health checks */
        { "fall",                srv_parse_check_fall,          1,  1,  1 }, /* Set fall value for health checks */