mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-04 12:32:23 +00:00
[MINOR] server tracking: don't care about the tracked server's mode
Right now, an HTTP server cannot track a TCP server and vice-versa. This patch enables proxy tracking without relying on the proxy's mode (tcp/http/health). It only requires a matching proxy name to exist. The original function was renamed to findproxy_mode().
This commit is contained in:
parent
4c84822d97
commit
96532db923
@ -39,7 +39,8 @@ int session_set_backend(struct session *s, struct proxy *be);
|
|||||||
|
|
||||||
const char *proxy_cap_str(int cap);
|
const char *proxy_cap_str(int cap);
|
||||||
const char *proxy_mode_str(int mode);
|
const char *proxy_mode_str(int mode);
|
||||||
struct proxy *findproxy(const char *name, int mode, int cap);
|
struct proxy *findproxy_mode(const char *name, int mode, int cap);
|
||||||
|
struct proxy *findproxy(const char *name, int cap);
|
||||||
struct server *findserver(const struct proxy *px, const char *name);
|
struct server *findserver(const struct proxy *px, const char *name);
|
||||||
int proxy_cfg_ensure_no_http(struct proxy *curproxy);
|
int proxy_cfg_ensure_no_http(struct proxy *curproxy);
|
||||||
int get_backend_server(const char *bk_name, const char *sv_name,
|
int get_backend_server(const char *bk_name, const char *sv_name,
|
||||||
|
@ -4166,7 +4166,7 @@ int check_config_validity()
|
|||||||
if (curproxy->defbe.name) {
|
if (curproxy->defbe.name) {
|
||||||
struct proxy *target;
|
struct proxy *target;
|
||||||
|
|
||||||
target = findproxy(curproxy->defbe.name, curproxy->mode, PR_CAP_BE);
|
target = findproxy_mode(curproxy->defbe.name, curproxy->mode, PR_CAP_BE);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
Alert("Proxy '%s': unable to find required default_backend: '%s'.\n",
|
Alert("Proxy '%s': unable to find required default_backend: '%s'.\n",
|
||||||
curproxy->id, curproxy->defbe.name);
|
curproxy->id, curproxy->defbe.name);
|
||||||
@ -4196,7 +4196,7 @@ int check_config_validity()
|
|||||||
if (exp->action != ACT_SETBE)
|
if (exp->action != ACT_SETBE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
target = findproxy(exp->replace, PR_MODE_HTTP, PR_CAP_BE);
|
target = findproxy_mode(exp->replace, PR_MODE_HTTP, PR_CAP_BE);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
Alert("Proxy '%s': unable to find required setbe: '%s'.\n",
|
Alert("Proxy '%s': unable to find required setbe: '%s'.\n",
|
||||||
curproxy->id, exp->replace);
|
curproxy->id, exp->replace);
|
||||||
@ -4221,7 +4221,7 @@ int check_config_validity()
|
|||||||
list_for_each_entry(rule, &curproxy->switching_rules, list) {
|
list_for_each_entry(rule, &curproxy->switching_rules, list) {
|
||||||
struct proxy *target;
|
struct proxy *target;
|
||||||
|
|
||||||
target = findproxy(rule->be.name, curproxy->mode, PR_CAP_BE);
|
target = findproxy_mode(rule->be.name, curproxy->mode, PR_CAP_BE);
|
||||||
|
|
||||||
if (!target) {
|
if (!target) {
|
||||||
Alert("Proxy '%s': unable to find required use_backend: '%s'.\n",
|
Alert("Proxy '%s': unable to find required use_backend: '%s'.\n",
|
||||||
@ -4433,7 +4433,7 @@ int check_config_validity()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pname) {
|
if (pname) {
|
||||||
px = findproxy(pname, curproxy->mode, PR_CAP_BE);
|
px = findproxy(pname, PR_CAP_BE);
|
||||||
if (!px) {
|
if (!px) {
|
||||||
Alert("config : %s '%s', server '%s': unable to find required proxy '%s' for tracking.\n",
|
Alert("config : %s '%s', server '%s': unable to find required proxy '%s' for tracking.\n",
|
||||||
proxy_type_str(curproxy), curproxy->id,
|
proxy_type_str(curproxy), curproxy->id,
|
||||||
@ -4455,7 +4455,7 @@ int check_config_validity()
|
|||||||
|
|
||||||
if (!(srv->state & SRV_CHECKED)) {
|
if (!(srv->state & SRV_CHECKED)) {
|
||||||
Alert("config : %s '%s', server '%s': unable to use %s/%s for "
|
Alert("config : %s '%s', server '%s': unable to use %s/%s for "
|
||||||
"tracing as it does not have checks enabled.\n",
|
"tracking as it does not have checks enabled.\n",
|
||||||
proxy_type_str(curproxy), curproxy->id,
|
proxy_type_str(curproxy), curproxy->id,
|
||||||
newsrv->id, px->id, srv->id);
|
newsrv->id, px->id, srv->id);
|
||||||
cfgerr++;
|
cfgerr++;
|
||||||
|
21
src/proxy.c
21
src/proxy.c
@ -281,7 +281,7 @@ static int proxy_parse_rate_limit(char **args, int section, struct proxy *proxy,
|
|||||||
* requested name as this often leads into unexpected situations.
|
* requested name as this often leads into unexpected situations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct proxy *findproxy(const char *name, int mode, int cap) {
|
struct proxy *findproxy_mode(const char *name, int mode, int cap) {
|
||||||
|
|
||||||
struct proxy *curproxy, *target = NULL;
|
struct proxy *curproxy, *target = NULL;
|
||||||
|
|
||||||
@ -311,6 +311,25 @@ struct proxy *findproxy(const char *name, int mode, int cap) {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct proxy *findproxy(const char *name, int cap) {
|
||||||
|
|
||||||
|
struct proxy *curproxy, *target = NULL;
|
||||||
|
|
||||||
|
for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
|
||||||
|
if ((curproxy->cap & cap)!=cap || strcmp(curproxy->id, name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!target) {
|
||||||
|
target = curproxy;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function finds a server with matching name within selected proxy.
|
* This function finds a server with matching name within selected proxy.
|
||||||
* It also checks if there are more matching servers with
|
* It also checks if there are more matching servers with
|
||||||
|
Loading…
Reference in New Issue
Block a user