mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-03-15 03:51:13 +01:00
MINOR: proxy: check default proxy compatibility on "add backend"
This commits completes "add backend" handler with some checks performed on the specified default proxy instance. These are additional checks outside of the already existing inheritance rules, specific to dynamic backends. For now, a default proxy is considered not compatible if it is not in mode TCP/HTTP. Also, a default proxy is rejected if it references HTTP errors. This limitation may be lifted in the future, when HTTP errors are partiallay reworked.
This commit is contained in:
parent
a603811aac
commit
07195a1af4
@ -1738,6 +1738,13 @@ add backend <name> from <defproxy> [mode <mode>] [guid <guid>] [ EXPERIMENTAL ]
|
||||
in the unpublished state. Once considered ready for traffic, use "publish
|
||||
backend" to expose the newly created instance.
|
||||
|
||||
All named default proxies can be used, given that they validate the same
|
||||
inheritance rules applied during configuration parsing. There is some
|
||||
exceptions though, for example when the mode is neither TCP nor HTTP. Another
|
||||
exception is that it is not yet possible to use a default proxies which
|
||||
reference custom HTTP errors, for example via the errorfiles or http-rules
|
||||
keywords.
|
||||
|
||||
This command is restricted and can only be issued on sockets configured for
|
||||
level "admin". Moreover, this feature is still considered in development so it
|
||||
also requires experimental mode (see "experimental-mode on").
|
||||
|
||||
@ -4851,6 +4851,15 @@ static int cli_parse_add_backend(char **args, char *payload, struct appctx *appc
|
||||
cli_dynerr(appctx, memprintf(&msg, "Mode is required as '%s' default proxy does not explicitely defines it.\n", def_name));
|
||||
return 1;
|
||||
}
|
||||
if (defpx->mode != PR_MODE_TCP && defpx->mode != PR_MODE_HTTP) {
|
||||
cli_dynerr(appctx, memprintf(&msg, "Dynamic backends only support TCP or HTTP mode, whereas default proxy '%s' uses 'mode %s'.\n",
|
||||
def_name, proxy_mode_str(defpx->mode)));
|
||||
return 1;
|
||||
}
|
||||
if (!LIST_ISEMPTY(&defpx->conf.errors)) {
|
||||
cli_dynerr(appctx, memprintf(&msg, "Dynamic backends cannot inherit from default proxy '%s' because it references HTTP errors.\n", def_name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
thread_isolate();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user