MEDIUM: server: Inherit CLI weight changes and agent-check weight responses

When agent-check or CLI command executes relative weight change this patch
propagates it to tracking server allowing grouping many backends running on
same server underneath. Additionaly in case with many src IPs many backends
can have shared state checker, so there won't be unnecessary health checks.

[wt: Note: this will induce some behaviour change on some setups]
This commit is contained in:
Michal Idzikowski 2017-03-27 14:45:49 +02:00 committed by Willy Tarreau
parent a9e2e4b899
commit 266b1a8336
3 changed files with 37 additions and 0 deletions

View File

@ -11422,6 +11422,10 @@ track [<proxy>/]<server>
enabled. If <proxy> is omitted the current one is used. If disable-on-404 is
used, it has to be enabled on both proxies.
Note:
Relative weight changes are propagated to all tracking servers. Each
tracking server will have its weight recalculated separately.
tlsv10
This option may be used as "server" setting to reset any "no-tlsv10"
setting which would have been inherited from "default-server" directive as

View File

@ -1694,6 +1694,10 @@ set weight <backend>/<server> <weight>[%]
"admin". Both the backend and the server may be specified either by their
name or by their numeric ID, prefixed with a sharp ('#').
Note:
Relative weight changes are propagated to all tracking servers. Each
tracking server will have its weight recalculated separately.
show cli sockets
List CLI sockets. The output format is composed of 3 fields separated by
spaces. The first field is the socket address, it can be a unix socket, a

View File

@ -47,6 +47,9 @@
static void srv_update_state(struct server *srv, int version, char **params);
static int srv_apply_lastaddr(struct server *srv, int *err_code);
const char *server_propagate_weight_change_request(struct server *sv,
const char *weight_str);
/* List head of all known server keywords */
static struct srv_kw_list srv_keywords = {
.list = LIST_HEAD_INIT(srv_keywords.list)
@ -1445,6 +1448,8 @@ const char *server_parse_weight_change_request(struct server *sv,
struct proxy *px;
long int w;
char *end;
const char *msg;
int relative = 0;
px = sv->proxy;
@ -1466,6 +1471,8 @@ const char *server_parse_weight_change_request(struct server *sv,
w = sv->iweight * w / 100;
if (w > 256)
w = 256;
relative = 1;
}
else if (w < 0 || w > 256)
return "Absolute weight can only be between 0 and 256 inclusive.\n";
@ -1478,6 +1485,28 @@ const char *server_parse_weight_change_request(struct server *sv,
sv->uweight = w;
server_recalc_eweight(sv);
if (relative) {
msg = server_propagate_weight_change_request(sv, weight_str);
if (msg != NULL) {
return msg;
}
}
return NULL;
}
const char *server_propagate_weight_change_request(struct server *sv,
const char *weight_str)
{
struct server *tracker;
const char *msg;
for (tracker = sv->trackers; tracker; tracker = tracker->tracknext) {
msg = server_parse_weight_change_request(tracker, weight_str);
if (msg)
return msg;
}
return NULL;
}