]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: allow cookie for dynamic servers
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 27 Mar 2024 09:50:21 +0000 (10:50 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 28 Mar 2024 10:54:21 +0000 (11:54 +0100)
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.

doc/management.txt
src/server.c

index d5d2636b747e966831fdaedd419bba2574261757..9ddf103f2a0917c691bf5f07ac0c0357015e435b 100644 (file)
@@ -1692,6 +1692,7 @@ add server <backend>/<server> [args]*
   - check-via-socks4
   - ciphers
   - ciphersuites
+  - cookie
   - crl-file
   - crt
   - disabled
index 008335bfe0c1d0ea5450bbc9d224398dbb2d4039..ea93e1ff4f45e80ba0a5e9eaf73e2e7a6e4fd33f 100644 (file)
@@ -2216,7 +2216,7 @@ void srv_compute_all_admin_states(struct proxy *px)
  */
 static struct srv_kw_list srv_kws = { "ALL", { }, {
        { "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 */
        { "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 */
@@ -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");
        }
 
+       if (srv->cklen && be->mode != PR_MODE_HTTP)
+               ha_warning("Ignoring cookie as HTTP mode is disabled.\n");
+
        ha_notice("New server registered.\n");
        cli_umsg(appctx, LOG_INFO);