]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: spoe: Register the variable to set when an error occurred
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 21 Mar 2018 13:12:17 +0000 (14:12 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Apr 2018 13:13:53 +0000 (15:13 +0200)
Variables referenced in HAProxy's configuration file are registered during the
configuration parsing (during parsing of "var", "set-var" or "unset-var"
keywords). For the SPOE, you can use "register-var-names" directive to
explicitly register variable names. All unknown variables will be rejected
(unless you set "force-set-var" option). But, the variable set when an error
occurred (when "set-on-error" option is defined) should also be regiestered by
default. This is done with this patch.

src/flt_spoe.c

index 5dba391a00781bb14ba33e3bf8ab1cbdab70ddff..befa611a065986958ebf63233f2e6c473524742a 100644 (file)
@@ -3902,6 +3902,22 @@ parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
        if (curagent->engine_id == NULL)
                curagent->engine_id = generate_pseudo_uuid();
 
+       if (curagent->var_on_error) {
+               struct arg arg;
+
+               trash.len = snprintf(trash.str, trash.size, "txn.%s.%s",
+                                    curagent->var_pfx, curagent->var_on_error);
+
+               arg.type = ARGT_STR;
+               arg.data.str.str = trash.str;
+               arg.data.str.len = trash.len;
+               if (!vars_check_arg(&arg, err)) {
+                       memprintf(err, "SPOE agent '%s': failed to register variable %s.%s (%s)",
+                                 curagent->id, curagent->var_pfx, curagent->var_on_error, *err);
+                       goto error;
+               }
+       }
+
        if (LIST_ISEMPTY(&curmphs) && LIST_ISEMPTY(&curgphs)) {
                ha_warning("Proxy '%s': No message/group used by SPOE agent '%s' declared at %s:%d.\n",
                           px->id, curagent->id, curagent->conf.file, curagent->conf.line);