]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse-listen: warn when use-server rules is used in wrong mode
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 22 Sep 2023 13:07:25 +0000 (15:07 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Oct 2023 13:34:30 +0000 (15:34 +0200)
haproxy will report a warning when "use-server" keyword is used within a
backend that doesn't support server rules to inform the user that rules
will be ignored.

To this day, only TCP and HTTP backends can make use of it.

src/cfgparse-listen.c

index e5aafa0b98d3e18f2def845d979c489922ee395d..bd71111b8a5057a71bb70c835577d61c719198da 100644 (file)
@@ -1442,6 +1442,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
                        err_code |= ERR_WARN;
 
+               if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) {
+                       err_code |= ERR_WARN;
+                       ha_warning("parsing [%s:%d] : '%s' rules will be ignored for %s backend '%s' (unsupported mode).\n", file, linenum, args[0], proxy_mode_str(curproxy->mode), curproxy->id);
+               }
+
                if (*(args[1]) == 0) {
                        ha_alert("parsing [%s:%d] : '%s' expects a server name.\n", file, linenum, args[0]);
                        err_code |= ERR_ALERT | ERR_FATAL;