weight is reported on the stats page as "DRAIN" since it has the same
effect on the server (it's removed from the LB farm).
+ - The string "maxconn:" followed by an integer (no space between). Values in
+ this format will set the maxconn of a server. The maximum number of
+ connections advertised needs to be multipled by the number of load balancers
+ and different backends that use this health check to get the total number
+ of connections the server might receive. Example: maxconn:30
+
- The word "ready". This will turn the server's administrative state to the
READY mode, thus cancelling any DRAIN or MAINT state
const char *server_parse_addr_change_request(struct server *sv,
const char *addr_str, const char *updater);
+/*
+ * Parses maxconn_str and configures sv accordingly.
+ * Returns NULL on success, error message string otherwise.
+ */
+const char *server_parse_maxconn_change_request(struct server *sv,
+ const char *maxconn_str);
+
/*
* Return true if the server has a zero user-weight, meaning it's in draining
* mode (ie: not taking new non-persistent connections).
const char *hs = NULL; /* health status */
const char *as = NULL; /* admin status */
const char *ps = NULL; /* performance status */
+ const char *cs = NULL; /* maxconn */
const char *err = NULL; /* first error to report */
const char *wrn = NULL; /* first warning to report */
char *cmd, *p;
else if (strcasecmp(cmd, "maint") == 0) {
as = cmd;
}
- /* else try to parse a weight here and keep the last one */
+ /* try to parse a weight here and keep the last one */
else if (isdigit((unsigned char)*cmd) && strchr(cmd, '%') != NULL) {
ps = cmd;
}
+ /* try to parse a maxconn here */
+ else if (strncasecmp(cmd, "maxconn:", strlen("maxconn:")) == 0) {
+ cs = cmd;
+ }
else {
/* keep a copy of the first error */
if (!err)
wrn = msg;
}
+ if (cs) {
+ const char *msg;
+
+ cs += strlen("maxconn:");
+
+ msg = server_parse_maxconn_change_request(s, cs);
+ if (!wrn || !*wrn)
+ wrn = msg;
+ }
+
/* and finally health status */
if (hs) {
/* We'll report some of the warnings and errors we have
return "Could not understand IP address format.\n";
}
+const char *server_parse_maxconn_change_request(struct server *sv,
+ const char *maxconn_str)
+{
+ long int v;
+ char *end;
+
+ if (!*maxconn_str)
+ return "Require <maxconn>.\n";
+
+ v = strtol(maxconn_str, &end, 10);
+ if (end == maxconn_str)
+ return "maxconn string empty or preceded by garbage";
+ else if (end[0] != '\0')
+ return "Trailing garbage in maxconn string";
+
+ if (sv->maxconn == sv->minconn) { // static maxconn
+ sv->maxconn = sv->minconn = v;
+ } else { // dynamic maxconn
+ sv->maxconn = v;
+ }
+
+ if (may_dequeue_tasks(sv, sv->proxy))
+ process_srv_queue(sv);
+
+ return NULL;
+}
+
int parse_server(const char *file, int linenum, char **args, struct proxy *curproxy, struct proxy *defproxy)
{
struct server *newsrv = NULL;