MINOR: server: allow cookie for dynamic servers

This commit allows "cookie" keyword for dynamic servers. After code
review, nothing was found which could prevent a dynamic server to use
it. An extra warning is added under cli_parse_add_server() if cookie
value is ignored due to a non HTTP backend.

This patch is not considered a bugfix. However, it may backported if
needed as its impact seems minimal.
This commit is contained in:
Amaury Denoyelle 2024-03-27 10:50:21 +01:00
parent 9a0e0d3a19
commit 6333e6ec8e
2 changed files with 5 additions and 1 deletions

View File

@ -1692,6 +1692,7 @@ add server <backend>/<server> [args]*
- check-via-socks4 - check-via-socks4
- ciphers - ciphers
- ciphersuites - ciphersuites
- cookie
- crl-file - crl-file
- crt - crt
- disabled - disabled

View File

@ -2216,7 +2216,7 @@ void srv_compute_all_admin_states(struct proxy *px)
*/ */
static struct srv_kw_list srv_kws = { "ALL", { }, { static struct srv_kw_list srv_kws = { "ALL", { }, {
{ "backup", srv_parse_backup, 0, 1, 1 }, /* Flag as backup server */ { "backup", srv_parse_backup, 0, 1, 1 }, /* Flag as backup server */
{ "cookie", srv_parse_cookie, 1, 1, 0 }, /* Assign a cookie to the server */ { "cookie", srv_parse_cookie, 1, 1, 1 }, /* Assign a cookie to the server */
{ "disabled", srv_parse_disabled, 0, 1, 1 }, /* Start the server in 'disabled' state */ { "disabled", srv_parse_disabled, 0, 1, 1 }, /* Start the server in 'disabled' state */
{ "enabled", srv_parse_enabled, 0, 1, 0 }, /* Start the server in 'enabled' state */ { "enabled", srv_parse_enabled, 0, 1, 0 }, /* Start the server in 'enabled' state */
{ "error-limit", srv_parse_error_limit, 1, 1, 1 }, /* Configure the consecutive count of check failures to consider a server on error */ { "error-limit", srv_parse_error_limit, 1, 1, 1 }, /* Configure the consecutive count of check failures to consider a server on error */
@ -5758,6 +5758,9 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
ha_alert("System might be unstable, consider to execute a reload\n"); ha_alert("System might be unstable, consider to execute a reload\n");
} }
if (srv->cklen && be->mode != PR_MODE_HTTP)
ha_warning("Ignoring cookie as HTTP mode is disabled.\n");
ha_notice("New server registered.\n"); ha_notice("New server registered.\n");
cli_umsg(appctx, LOG_INFO); cli_umsg(appctx, LOG_INFO);