mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 20:46:11 +02:00
MINOR: check: allocate default check ruleset for every backends
Allocate default tcp ruleset for every backend without explicit rules defined, even if no server in the backend use check. This change is required to implement checks for dynamic servers. This allocation is done on check_config_validity. It must absolutely be called before check_proxy_tcpcheck (called via post proxy check) which allocate the implicit tcp connect rule.
This commit is contained in:
parent
fca18172d9
commit
f2c27a5c67
@ -80,6 +80,7 @@
|
||||
#include <haproxy/stream.h>
|
||||
#include <haproxy/task.h>
|
||||
#include <haproxy/tcp_rules.h>
|
||||
#include <haproxy/tcpcheck.h>
|
||||
#include <haproxy/thread.h>
|
||||
#include <haproxy/time.h>
|
||||
#include <haproxy/tools.h>
|
||||
@ -3588,6 +3589,32 @@ out_uri_auth_compat:
|
||||
/* update the mux */
|
||||
newsrv->mux_proto = mux_ent;
|
||||
}
|
||||
|
||||
/* Allocate default tcp-check rules for proxies without
|
||||
* explicit rules.
|
||||
*/
|
||||
if (curproxy->cap & PR_CAP_BE) {
|
||||
if (!(curproxy->options2 & PR_O2_CHK_ANY)) {
|
||||
struct tcpcheck_ruleset *rs = NULL;
|
||||
struct tcpcheck_rules *rules = &curproxy->tcpcheck_rules;
|
||||
|
||||
curproxy->options2 |= PR_O2_TCPCHK_CHK;
|
||||
|
||||
rs = find_tcpcheck_ruleset("*tcp-check");
|
||||
if (!rs) {
|
||||
rs = create_tcpcheck_ruleset("*tcp-check");
|
||||
if (rs == NULL) {
|
||||
ha_alert("config: %s '%s': out of memory.\n",
|
||||
proxy_type_str(curproxy), curproxy->id);
|
||||
cfgerr++;
|
||||
}
|
||||
}
|
||||
|
||||
free_tcpcheck_vars(&rules->preset_vars);
|
||||
rules->list = &rs->rules;
|
||||
rules->flags = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
24
src/check.c
24
src/check.c
@ -1639,30 +1639,6 @@ static int init_srv_check(struct server *srv)
|
||||
}
|
||||
|
||||
init:
|
||||
if (!(srv->proxy->options2 & PR_O2_CHK_ANY)) {
|
||||
struct tcpcheck_ruleset *rs = NULL;
|
||||
struct tcpcheck_rules *rules = &srv->proxy->tcpcheck_rules;
|
||||
//char *errmsg = NULL;
|
||||
|
||||
srv->proxy->options2 &= ~PR_O2_CHK_ANY;
|
||||
srv->proxy->options2 |= PR_O2_TCPCHK_CHK;
|
||||
|
||||
rs = find_tcpcheck_ruleset("*tcp-check");
|
||||
if (!rs) {
|
||||
rs = create_tcpcheck_ruleset("*tcp-check");
|
||||
if (rs == NULL) {
|
||||
ha_alert("config: %s '%s': out of memory.\n",
|
||||
proxy_type_str(srv->proxy), srv->proxy->id);
|
||||
ret |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
free_tcpcheck_vars(&rules->preset_vars);
|
||||
rules->list = &rs->rules;
|
||||
rules->flags = 0;
|
||||
}
|
||||
|
||||
err = init_check(&srv->check, srv->proxy->options2 & PR_O2_CHK_ANY);
|
||||
if (err) {
|
||||
ha_alert("config: %s '%s': unable to init check for server '%s' (%s).\n",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user