MEDIUM: check: align agentaddr and agentport behaviour

in the same manner of agentaddr, we now:
- permit to set agentport through `port` keyword, like it is the case
  for agentaddr through `addr`
- set the priority on `agent-port` keyword when used
- add a flag to be able to test when the value is set like for agentaddr

it makes the behaviour between `addr` and `port` more consistent.

Signed-off-by: William Dauchy <wdauchy@gmail.com>
This commit is contained in:
William Dauchy 2021-02-03 22:30:09 +01:00 committed by Christopher Faulet
parent 1c921cd748
commit 4858fb2e18
4 changed files with 18 additions and 6 deletions

View File

@ -14061,11 +14061,11 @@ pool-purge-delay <delay>
port <port>
Using the "port" parameter, it becomes possible to use a different port to
send health-checks. On some servers, it may be desirable to dedicate a port
to a specific component able to perform complex tests which are more suitable
to health-checks than the application. It is common to run a simple script in
inetd for instance. This parameter is ignored if the "check" parameter is not
set. See also the "addr" parameter.
send health-checks or to probe the agent-check. On some servers, it may be
desirable to dedicate a port to a specific component able to perform complex
tests which are more suitable to health-checks than the application. It is
common to run a simple script in inetd for instance. This parameter is
ignored if the "check" parameter is not set. See also the "addr" parameter.
proto <name>
Forces the multiplexer's protocol to use for the outgoing connections to this

View File

@ -53,6 +53,7 @@ int spoe_handle_healthcheck_response(char *frame, size_t size, char *err, int er
int set_srv_agent_send(struct server *srv, const char *send);
void set_srv_agent_addr(struct server *srv, struct sockaddr_storage *sk);
void set_srv_agent_port(struct server *srv, int port);
/* Use this one only. This inline version only ensures that we don't
* call the function when the observe mode is disabled.

View File

@ -138,6 +138,7 @@ enum srv_initaddr {
#define SRV_F_NON_STICK 0x0004 /* never add connections allocated to this server to a stick table */
#define SRV_F_USE_NS_FROM_PP 0x0008 /* use namespace associated with connection if present */
#define SRV_F_FORCED_ID 0x0010 /* server's ID was forced in the configuration */
#define SRV_F_AGENTPORT 0x0040 /* this server has a agent port configured */
#define SRV_F_AGENTADDR 0x0080 /* this server has a agent addr configured */
#define SRV_F_COOKIESET 0x0100 /* this server has a cookie configured, so don't generate dynamic cookies */
#define SRV_F_FASTOPEN 0x0200 /* Use TCP Fast Open to connect to server */

View File

@ -1697,7 +1697,7 @@ static int srv_parse_agent_port(char **args, int *cur_arg, struct proxy *curpx,
}
global.maxsock++;
srv->agent.port = atol(args[*cur_arg+1]);
set_srv_agent_port(srv, atol(args[*cur_arg + 1]));
out:
return err_code;
@ -1741,6 +1741,13 @@ inline void set_srv_agent_addr(struct server *srv, struct sockaddr_storage *sk)
srv->flags |= SRV_F_AGENTADDR;
}
/* set agent port and apprropriate flag */
inline void set_srv_agent_port(struct server *srv, int port)
{
srv->agent.port = port;
srv->flags |= SRV_F_AGENTPORT;
}
/* Parse the "agent-send" server keyword */
static int srv_parse_agent_send(char **args, int *cur_arg, struct proxy *curpx, struct server *srv,
char **errmsg)
@ -2060,6 +2067,9 @@ static int srv_parse_check_port(char **args, int *cur_arg, struct proxy *curpx,
global.maxsock++;
srv->check.port = atol(args[*cur_arg+1]);
/* if agentport was never set, we can use port */
if (!(srv->flags & SRV_F_AGENTPORT))
srv->agent.port = srv->check.port;
out:
return err_code;