MINOR: server: support keyword proto in 'add server' cli
Allow to specify the mux proto for a dynamic server. It must be compatible with the backend mode to be accepted. The reg-tests has been extended for this error case.
This commit is contained in:
parent
fc465a54fd
commit
304672320e
@ -1447,6 +1447,7 @@ add server <backend>/<server> [args]*
|
||||
- pool-low-conn
|
||||
- pool-max-conn
|
||||
- pool-purge-delay
|
||||
- proto
|
||||
- proxy-v2-options
|
||||
- send-proxy
|
||||
- send-proxy-v2
|
||||
|
@ -26,6 +26,10 @@ haproxy h1 -conf {
|
||||
|
||||
backend other
|
||||
balance static-rr
|
||||
|
||||
backend other2
|
||||
balance random
|
||||
mode tcp
|
||||
} -start
|
||||
|
||||
client c1 -connect ${h1_feS_sock} {
|
||||
@ -51,6 +55,10 @@ haproxy h1 -cli {
|
||||
send "experimental-mode on; add server other/s1 ${s1_addr}:${s1_port}"
|
||||
expect ~ "Backend must use a consistent hashing method for load balancing to support dynamic servers."
|
||||
|
||||
# invalid mux proto
|
||||
send "experimental-mode on; add server other2/s1 ${s1_addr}:${s1_port} proto h2"
|
||||
expect ~ "MUX protocol is not usable for server."
|
||||
|
||||
# valid command
|
||||
send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
|
||||
expect ~ "New server registered."
|
||||
@ -58,6 +66,11 @@ haproxy h1 -cli {
|
||||
# duplicate server
|
||||
send "experimental-mode on; add server test/s1 ${s1_addr}:${s1_port}"
|
||||
expect ~ "Already exists a server with the same name in backend."
|
||||
|
||||
# valid command
|
||||
# specify the proto, it should be accepted for this backend
|
||||
send "experimental-mode on; add server test/s2 ${s1_addr}:${s1_port} proto h2"
|
||||
expect ~ "New server registered."
|
||||
}
|
||||
|
||||
# dynamic servers are created on MAINT mode and should not be available at first
|
||||
|
@ -1651,7 +1651,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, {
|
||||
{ "pool-low-conn", srv_parse_pool_low_conn, 1, 1, 1 }, /* Set the min number of orphan idle connecbefore being allowed to pick from other threads */
|
||||
{ "pool-max-conn", srv_parse_pool_max_conn, 1, 1, 1 }, /* Set the max number of orphan idle connections, -1 means unlimited */
|
||||
{ "pool-purge-delay", srv_parse_pool_purge_delay, 1, 1, 1 }, /* Set the time before we destroy orphan idle connections, defaults to 1s */
|
||||
{ "proto", srv_parse_proto, 1, 1, 0 }, /* Set the proto to use for all outgoing connections */
|
||||
{ "proto", srv_parse_proto, 1, 1, 1 }, /* Set the proto to use for all outgoing connections */
|
||||
{ "proxy-v2-options", srv_parse_proxy_v2_options, 1, 1, 1 }, /* options for send-proxy-v2 */
|
||||
{ "redir", srv_parse_redir, 1, 1, 0 }, /* Enable redirection mode */
|
||||
{ "resolve-net", srv_parse_resolve_net, 1, 1, 0 }, /* Set the prefered network range for name resolution */
|
||||
@ -4377,6 +4377,13 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (srv->mux_proto) {
|
||||
if (!conn_get_best_mux_entry(srv->mux_proto->token, PROTO_SIDE_BE, be->mode)) {
|
||||
cli_err(appctx, "MUX protocol is not usable for server.");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
srv->per_thr = calloc(global.nbthread, sizeof(*srv->per_thr));
|
||||
if (!srv->per_thr) {
|
||||
cli_err(appctx, "failed to allocate per-thread lists for server.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user