mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
[MINOR] cfgparse: set backends to "balance roundrobin" by default
When a backend has no LB algo specified and is not in dispatch, proxy nor transparent mode, use "balance roundrobin" by default instead of complaining. This will be particularly useful with stats and redirects.
This commit is contained in:
parent
ff01a21ebe
commit
3cd9af228f
@ -857,8 +857,9 @@ balance url_param <param> [check_post [<max_wait>]]
|
|||||||
balance uri [len <len>] [depth <depth>]
|
balance uri [len <len>] [depth <depth>]
|
||||||
balance url_param <param> [check_post [<max_wait>]]
|
balance url_param <param> [check_post [<max_wait>]]
|
||||||
|
|
||||||
The definition of the load balancing algorithm is mandatory for a backend
|
The load balancing algorithm of a backend is set to roundrobin when no other
|
||||||
and limited to one per backend.
|
algorithm, mode nor option have been set. The algorithm may only be set once
|
||||||
|
for each backend.
|
||||||
|
|
||||||
Examples :
|
Examples :
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
|
@ -3146,32 +3146,33 @@ int readcfgfile(const char *file)
|
|||||||
cfgerr++;
|
cfgerr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curproxy->cap & PR_CAP_BE &&
|
if ((curproxy->cap & PR_CAP_BE) && (curproxy->mode != PR_MODE_HEALTH)) {
|
||||||
((curproxy->mode != PR_MODE_HEALTH) &&
|
if (curproxy->lbprm.algo & BE_LB_ALGO) {
|
||||||
!(curproxy->options & (PR_O_TRANSP | PR_O_HTTP_PROXY)) &&
|
if (curproxy->options & PR_O_TRANSP) {
|
||||||
!(curproxy->lbprm.algo & BE_LB_ALGO) &&
|
Alert("parsing %s : %s '%s' cannot use both transparent and balance mode.\n",
|
||||||
(*(int *)&curproxy->dispatch_addr.sin_addr == 0))) {
|
file, proxy_type_str(curproxy), curproxy->id);
|
||||||
Alert("parsing %s : %s '%s' has no dispatch address and is not in transparent or balance mode.\n",
|
cfgerr++;
|
||||||
file, proxy_type_str(curproxy), curproxy->id);
|
}
|
||||||
cfgerr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((curproxy->mode != PR_MODE_HEALTH) && (curproxy->lbprm.algo & BE_LB_ALGO)) {
|
|
||||||
if (curproxy->options & PR_O_TRANSP) {
|
|
||||||
Alert("parsing %s : %s '%s' cannot use both transparent and balance mode.\n",
|
|
||||||
file, proxy_type_str(curproxy), curproxy->id);
|
|
||||||
cfgerr++;
|
|
||||||
}
|
|
||||||
#ifdef WE_DONT_SUPPORT_SERVERLESS_LISTENERS
|
#ifdef WE_DONT_SUPPORT_SERVERLESS_LISTENERS
|
||||||
else if (curproxy->srv == NULL) {
|
else if (curproxy->srv == NULL) {
|
||||||
Alert("parsing %s : %s '%s' needs at least 1 server in balance mode.\n",
|
Alert("parsing %s : %s '%s' needs at least 1 server in balance mode.\n",
|
||||||
file, proxy_type_str(curproxy), curproxy->id);
|
file, proxy_type_str(curproxy), curproxy->id);
|
||||||
cfgerr++;
|
cfgerr++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (*(int *)&curproxy->dispatch_addr.sin_addr != 0) {
|
else if (*(int *)&curproxy->dispatch_addr.sin_addr != 0) {
|
||||||
Warning("parsing %s : dispatch address of %s '%s' will be ignored in balance mode.\n",
|
Warning("parsing %s : dispatch address of %s '%s' will be ignored in balance mode.\n",
|
||||||
file, proxy_type_str(curproxy), curproxy->id);
|
file, proxy_type_str(curproxy), curproxy->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!(curproxy->options & (PR_O_TRANSP | PR_O_HTTP_PROXY)) &&
|
||||||
|
(*(int *)&curproxy->dispatch_addr.sin_addr == 0)) {
|
||||||
|
/* If no LB algo is set in a backend, and we're not in
|
||||||
|
* transparent mode, dispatch mode nor proxy mode, we
|
||||||
|
* want to use balance roundrobin by default.
|
||||||
|
*/
|
||||||
|
curproxy->lbprm.algo &= ~BE_LB_ALGO;
|
||||||
|
curproxy->lbprm.algo |= BE_LB_ALGO_RR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user