int tcp_persist_rdp_cookie(struct stream *s, struct channel *req, int an_bit);
int be_downtime(struct proxy *px);
+int be_supports_dynamic_srv(struct proxy *px, char **msg);
void recount_servers(struct proxy *px);
void update_backend_weight(struct proxy *px);
# invalid load-balancing algo
send "add server other/s1 ${s1_addr}:${s1_port}"
- expect ~ "Backend must use a dynamic load balancing to support dynamic servers."
+ expect ~ "backend 'other' uses a non dynamic load balancing method"
# invalid mux proto
send "add server other2/s1 ${s1_addr}:${s1_port} proto h2"
#include <haproxy/task.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>
+#include <haproxy/tools.h>
#include <haproxy/trace.h>
#define TRACE_SOURCE &trace_strm
return ns_to_sec(now_ns) - px->last_change + px->down_time;
}
+/* Checks if <px> backend supports the addition of servers at runtime. Either a
+ * backend or a defaults proxy are supported. If proxy is incompatible, <msg>
+ * will be allocated to contain a textual explaination.
+ */
+int be_supports_dynamic_srv(struct proxy *px, char **msg)
+{
+ if (px->lbprm.algo && !(px->lbprm.algo & BE_LB_PROP_DYN)) {
+ memprintf(msg, "%s '%s' uses a non dynamic load balancing method",
+ proxy_cap_str(px->cap), px->id);
+ return 0;
+ }
+
+ if (px->mode == PR_MODE_SYSLOG) {
+ memprintf(msg, "%s '%s' uses mode log",
+ proxy_cap_str(px->cap), px->id);
+ return 0;
+ }
+
+ return 1;
+}
+
/*
* This function returns a string containing the balancing
* mode of the proxy in a format suitable for stats.
struct add_srv_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
struct proxy *be;
struct server *srv;
- char *be_name, *sv_name;
+ char *be_name, *sv_name, *errmsg;
int errcode, argc;
int next_id;
const int parse_flags = SRV_PARSE_DYNAMIC|SRV_PARSE_PARSE_ADDR;
if (!be)
return cli_err(appctx, "No such backend.\n");
- if (!(be->lbprm.algo & BE_LB_PROP_DYN)) {
- cli_err(appctx, "Backend must use a dynamic load balancing to support dynamic servers.\n");
- return 1;
- }
-
- if (be->mode == PR_MODE_SYSLOG) {
- cli_err(appctx," Dynamic servers cannot be used with log backends.\n");
+ errmsg = NULL;
+ if (!be_supports_dynamic_srv(be, &errmsg)) {
+ cli_dynerr(appctx, memprintf(&errmsg, "Backend does not support dynamic servers : %s.\n", errmsg));
return 1;
}