mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-16 16:34:42 +00:00
MINOR: checks: allow external checks in backend sections
Previously, external checks required to find at least one listener in order to pass the <proxy_address> and <proxy_port> arguments to the external script. It prevented from declaring external checks in backend sections and haproxy rejected the configuration. The listener is now optional and values "NOT_USED" are passed if no listener is found. For instance, this is the case with a backend section. This is specific to the 1.6 branch.
This commit is contained in:
parent
83f2592bcd
commit
777be861c5
@ -5338,13 +5338,14 @@ external-check command <command>
|
||||
|
||||
The arguments passed to the to the command are:
|
||||
|
||||
proxy_address proxy_port server_address server_port
|
||||
<proxy_address> <proxy_port> <server_address> <server_port>
|
||||
|
||||
The proxy_address and proxy_port are derived from the first listener
|
||||
that is either IPv4, IPv6 or a UNIX socket. It is an error for no such
|
||||
listeners to exist. In the case of a UNIX socket listener the
|
||||
proxy_address will be the path of the socket and the proxy_port will
|
||||
be the string "NOT_USED".
|
||||
The <proxy_address> and <proxy_port> are derived from the first listener
|
||||
that is either IPv4, IPv6 or a UNIX socket. In the case of a UNIX socket
|
||||
listener the proxy_address will be the path of the socket and the
|
||||
<proxy_port> will be the string "NOT_USED". In a backend section, it's not
|
||||
possible to determine a listener, and both <proxy_address> and <proxy_port>
|
||||
will have the string value "NOT_USED".
|
||||
|
||||
If the command executed and exits with a zero status then the check is
|
||||
considered to have passed, otherwise the check is considered to have
|
||||
|
17
src/checks.c
17
src/checks.c
@ -1589,11 +1589,6 @@ static int prepare_external_check(struct check *check)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!listener) {
|
||||
err_fmt = "Starting [%s:%s] check: no listener.\n";
|
||||
goto err;
|
||||
}
|
||||
|
||||
check->curpid = NULL;
|
||||
|
||||
check->envp = calloc(2, sizeof(check->argv));
|
||||
@ -1612,19 +1607,25 @@ static int prepare_external_check(struct check *check)
|
||||
|
||||
check->argv[0] = px->check_command;
|
||||
|
||||
if (listener->addr.ss_family == AF_INET ||
|
||||
if (!listener) {
|
||||
check->argv[1] = strdup("NOT_USED");
|
||||
check->argv[2] = strdup("NOT_USED");
|
||||
}
|
||||
else if (listener->addr.ss_family == AF_INET ||
|
||||
listener->addr.ss_family == AF_INET6) {
|
||||
addr_to_str(&listener->addr, host, sizeof(host));
|
||||
check->argv[1] = strdup(host);
|
||||
port_to_str(&listener->addr, serv, sizeof(serv));
|
||||
check->argv[2] = strdup(serv);
|
||||
} else if (listener->addr.ss_family == AF_UNIX) {
|
||||
}
|
||||
else if (listener->addr.ss_family == AF_UNIX) {
|
||||
const struct sockaddr_un *un;
|
||||
|
||||
un = (struct sockaddr_un *)&listener->addr;
|
||||
check->argv[1] = strdup(un->sun_path);
|
||||
check->argv[2] = strdup("NOT_USED");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user