mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
BUG/MEDIUM: server: do not forget to generate the dynamic servers ids
If no id is specified by the user for a dynamic server, it is necessary to generate a new one. This operation is now done at the end of 'add server' CLI handler. The server is then inserted into the proxy ids tree. Without this, several features may be broken for dynamic servers. Among them, there is the "first" lb algorithm, the persistence using stick-tables or the uniqueness internal check of srv_parse_id. This must be backported up to 2.4.
This commit is contained in:
parent
82d7f77463
commit
406aaef55a
20
src/server.c
20
src/server.c
@ -4317,7 +4317,7 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
struct server *srv;
|
||||
char *be_name, *sv_name;
|
||||
int errcode, argc;
|
||||
int i;
|
||||
int next_id, i;
|
||||
const int parse_flags = SRV_PARSE_DYNAMIC|SRV_PARSE_PARSE_ADDR;
|
||||
|
||||
usermsgs_clr("CLI");
|
||||
@ -4451,6 +4451,24 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
be->srv = srv;
|
||||
}
|
||||
|
||||
/* generate the server id if not manually specified */
|
||||
if (!srv->puid) {
|
||||
next_id = get_next_id(&be->conf.used_server_id, 1);
|
||||
if (!next_id) {
|
||||
ha_alert("Cannot attach server : no id left in proxy\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
srv->conf.id.key = srv->puid = next_id;
|
||||
srv->conf.name.key = srv->id;
|
||||
}
|
||||
|
||||
/* insert the server in the backend trees */
|
||||
if (!(srv->flags & SRV_F_FORCED_ID)) {
|
||||
eb32_insert(&be->conf.used_server_id, &srv->conf.id);
|
||||
ebis_insert(&be->conf.used_server_name, &srv->conf.name);
|
||||
}
|
||||
|
||||
thread_release();
|
||||
|
||||
ha_notice("New server registered.\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user