mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 14:21:00 +01:00
MINOR: server: Add 'no-agent-check' server keyword.
This patch adds 'no-agent-check' setting supported both by 'default-server'
and 'server' directives to disable an agent check for a specific server which would
have 'agent-check' set as default value (inherited from 'default-server'
'agent-check' setting), or, on 'default-server' lines, to disable 'agent-check' setting
as default value for any further 'server' declarations.
For instance, provided this configuration:
default-server agent-check
server srv1
server srv2 no-agent-check
server srv3
default-server no-agent-check
server srv4
srv1 and srv3 would have an agent check enabled contrary to srv2 and srv4.
We do not allocate anymore anything when parsing 'default-server' 'agent-check'
setting.
This commit is contained in:
parent
2a0d061a60
commit
6e0843c0e0
@ -241,6 +241,7 @@ struct server {
|
|||||||
int tcp_ut; /* for TCP, user timeout */
|
int tcp_ut; /* for TCP, user timeout */
|
||||||
|
|
||||||
int do_check; /* temporary variable used during parsing to denote if health checks must be enabled */
|
int do_check; /* temporary variable used during parsing to denote if health checks must be enabled */
|
||||||
|
int do_agent; /* temporary variable used during parsing to denote if an auxiliary agent check must be enabled */
|
||||||
struct check check; /* health-check specific configuration */
|
struct check check; /* health-check specific configuration */
|
||||||
struct check agent; /* agent specific configuration */
|
struct check agent; /* agent specific configuration */
|
||||||
|
|
||||||
|
|||||||
@ -3082,8 +3082,11 @@ const char *init_check(struct check *check, int type)
|
|||||||
void free_check(struct check *check)
|
void free_check(struct check *check)
|
||||||
{
|
{
|
||||||
free(check->bi);
|
free(check->bi);
|
||||||
|
check->bi = NULL;
|
||||||
free(check->bo);
|
free(check->bo);
|
||||||
|
check->bo = NULL;
|
||||||
free(check->conn);
|
free(check->conn);
|
||||||
|
check->conn = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void email_alert_free(struct email_alert *alert)
|
void email_alert_free(struct email_alert *alert)
|
||||||
|
|||||||
35
src/server.c
35
src/server.c
@ -262,6 +262,14 @@ static int srv_parse_addr(char **args, int *cur_arg,
|
|||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse the "agent-check" server keyword */
|
||||||
|
static int srv_parse_agent_check(char **args, int *cur_arg,
|
||||||
|
struct proxy *curproxy, struct server *newsrv, char **err)
|
||||||
|
{
|
||||||
|
newsrv->do_agent = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse the "backup" server keyword */
|
/* Parse the "backup" server keyword */
|
||||||
static int srv_parse_backup(char **args, int *cur_arg,
|
static int srv_parse_backup(char **args, int *cur_arg,
|
||||||
struct proxy *curproxy, struct server *newsrv, char **err)
|
struct proxy *curproxy, struct server *newsrv, char **err)
|
||||||
@ -401,6 +409,18 @@ static int srv_parse_namespace(char **args, int *cur_arg,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse the "no-agent-check" server keyword */
|
||||||
|
static int srv_parse_no_agent_check(char **args, int *cur_arg,
|
||||||
|
struct proxy *curproxy, struct server *newsrv, char **err)
|
||||||
|
{
|
||||||
|
free_check(&newsrv->agent);
|
||||||
|
newsrv->agent.inter = 0;
|
||||||
|
newsrv->agent.port = 0;
|
||||||
|
newsrv->agent.state &= ~CHK_ST_CONFIGURED & ~CHK_ST_ENABLED & ~CHK_ST_AGENT;
|
||||||
|
newsrv->do_agent = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse the "no-backup" server keyword */
|
/* Parse the "no-backup" server keyword */
|
||||||
static int srv_parse_no_backup(char **args, int *cur_arg,
|
static int srv_parse_no_backup(char **args, int *cur_arg,
|
||||||
struct proxy *curproxy, struct server *newsrv, char **err)
|
struct proxy *curproxy, struct server *newsrv, char **err)
|
||||||
@ -1341,6 +1361,7 @@ void srv_compute_all_admin_states(struct proxy *px)
|
|||||||
*/
|
*/
|
||||||
static struct srv_kw_list srv_kws = { "ALL", { }, {
|
static struct srv_kw_list srv_kws = { "ALL", { }, {
|
||||||
{ "addr", srv_parse_addr, 1, 1 }, /* IP address to send health to or to probe from agent-check */
|
{ "addr", srv_parse_addr, 1, 1 }, /* IP address to send health to or to probe from agent-check */
|
||||||
|
{ "agent-check", srv_parse_agent_check, 0, 1 }, /* Enable an auxiliary agent check */
|
||||||
{ "backup", srv_parse_backup, 0, 1 }, /* Flag as backup server */
|
{ "backup", srv_parse_backup, 0, 1 }, /* Flag as backup server */
|
||||||
{ "check", srv_parse_check, 0, 1 }, /* enable health checks */
|
{ "check", srv_parse_check, 0, 1 }, /* enable health checks */
|
||||||
{ "check-send-proxy", srv_parse_check_send_proxy, 0, 1 }, /* enable PROXY protocol for health checks */
|
{ "check-send-proxy", srv_parse_check_send_proxy, 0, 1 }, /* enable PROXY protocol for health checks */
|
||||||
@ -1349,6 +1370,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, {
|
|||||||
{ "enabled", srv_parse_enabled, 0, 1 }, /* Start the server in 'enabled' state */
|
{ "enabled", srv_parse_enabled, 0, 1 }, /* Start the server in 'enabled' state */
|
||||||
{ "id", srv_parse_id, 1, 0 }, /* set id# of server */
|
{ "id", srv_parse_id, 1, 0 }, /* set id# of server */
|
||||||
{ "namespace", srv_parse_namespace, 1, 1 }, /* Namespace the server socket belongs to (if supported) */
|
{ "namespace", srv_parse_namespace, 1, 1 }, /* Namespace the server socket belongs to (if supported) */
|
||||||
|
{ "no-agent-check", srv_parse_no_agent_check, 0, 1 }, /* Do not enable any auxiliary agent check */
|
||||||
{ "no-backup", srv_parse_no_backup, 0, 1 }, /* Flag as non-backup server */
|
{ "no-backup", srv_parse_no_backup, 0, 1 }, /* Flag as non-backup server */
|
||||||
{ "no-check", srv_parse_no_check, 0, 1 }, /* disable health checks */
|
{ "no-check", srv_parse_no_check, 0, 1 }, /* disable health checks */
|
||||||
{ "no-check-send-proxy", srv_parse_no_check_send_proxy, 0, 1 }, /* disable PROXY protol for health checks */
|
{ "no-check-send-proxy", srv_parse_no_check_send_proxy, 0, 1 }, /* disable PROXY protol for health checks */
|
||||||
@ -1569,7 +1591,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
|
|
||||||
if (!strcmp(args[0], "server") || !strcmp(args[0], "default-server")) { /* server address */
|
if (!strcmp(args[0], "server") || !strcmp(args[0], "default-server")) { /* server address */
|
||||||
int cur_arg;
|
int cur_arg;
|
||||||
int do_agent = 0, defsrv = (*args[0] == 'd');
|
int defsrv = (*args[0] == 'd');
|
||||||
|
|
||||||
if (!defsrv && curproxy == defproxy) {
|
if (!defsrv && curproxy == defproxy) {
|
||||||
Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
|
Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
|
||||||
@ -1619,7 +1641,6 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
LIST_INIT(&newsrv->priv_conns);
|
LIST_INIT(&newsrv->priv_conns);
|
||||||
LIST_INIT(&newsrv->idle_conns);
|
LIST_INIT(&newsrv->idle_conns);
|
||||||
LIST_INIT(&newsrv->safe_conns);
|
LIST_INIT(&newsrv->safe_conns);
|
||||||
do_agent = 0;
|
|
||||||
newsrv->flags = 0;
|
newsrv->flags = 0;
|
||||||
newsrv->admin = 0;
|
newsrv->admin = 0;
|
||||||
newsrv->state = SRV_ST_RUNNING; /* early server setup */
|
newsrv->state = SRV_ST_RUNNING; /* early server setup */
|
||||||
@ -1746,6 +1767,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
/* Note: 'flags' field has potentially been already initialized. */
|
/* Note: 'flags' field has potentially been already initialized. */
|
||||||
newsrv->flags |= curproxy->defsrv.flags;
|
newsrv->flags |= curproxy->defsrv.flags;
|
||||||
newsrv->do_check = curproxy->defsrv.do_check;
|
newsrv->do_check = curproxy->defsrv.do_check;
|
||||||
|
newsrv->do_agent = curproxy->defsrv.do_agent;
|
||||||
if (newsrv->check.port)
|
if (newsrv->check.port)
|
||||||
newsrv->flags |= SRV_F_CHECKPORT;
|
newsrv->flags |= SRV_F_CHECKPORT;
|
||||||
newsrv->check.inter = curproxy->defsrv.check.inter;
|
newsrv->check.inter = curproxy->defsrv.check.inter;
|
||||||
@ -1832,11 +1854,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (*args[cur_arg]) {
|
while (*args[cur_arg]) {
|
||||||
if (!strcmp(args[cur_arg], "agent-check")) {
|
if (!strcmp(args[cur_arg], "agent-inter")) {
|
||||||
global.maxsock++;
|
|
||||||
do_agent = 1;
|
|
||||||
cur_arg += 1;
|
|
||||||
} else if (!strcmp(args[cur_arg], "agent-inter")) {
|
|
||||||
const char *err = parse_time_err(args[cur_arg + 1], &val, TIME_UNIT_MS);
|
const char *err = parse_time_err(args[cur_arg + 1], &val, TIME_UNIT_MS);
|
||||||
if (err) {
|
if (err) {
|
||||||
Alert("parsing [%s:%d] : unexpected character '%c' in 'agent-inter' argument of server %s.\n",
|
Alert("parsing [%s:%d] : unexpected character '%c' in 'agent-inter' argument of server %s.\n",
|
||||||
@ -2322,7 +2340,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
global.maxsock++;
|
global.maxsock++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_agent) {
|
if (!defsrv && newsrv->do_agent) {
|
||||||
const char *ret;
|
const char *ret;
|
||||||
|
|
||||||
if (!newsrv->agent.port) {
|
if (!newsrv->agent.port) {
|
||||||
@ -2343,6 +2361,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
}
|
}
|
||||||
|
|
||||||
newsrv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED | CHK_ST_AGENT;
|
newsrv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED | CHK_ST_AGENT;
|
||||||
|
global.maxsock++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defsrv) {
|
if (!defsrv) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user