diff --git a/doc/configuration.txt b/doc/configuration.txt index 156130282..b1219b529 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -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 diff --git a/include/haproxy/check-t.h b/include/haproxy/check-t.h index eb080a93a..24cee86e9 100644 --- a/include/haproxy/check-t.h +++ b/include/haproxy/check-t.h @@ -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 */ diff --git a/src/check.c b/src/check.c index e46fc654b..52a55921f 100644 --- a/src/check.c +++ b/src/check.c @@ -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 */