From: Christopher Faulet Date: Wed, 21 Mar 2018 13:12:17 +0000 (+0100) Subject: BUG/MINOR: spoe: Register the variable to set when an error occurred X-Git-Tag: v1.9-dev1~320 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b7426d1562720b2bdd6eb4a94a7b536e123ce0f9;p=thirdparty%2Fhaproxy.git BUG/MINOR: spoe: Register the variable to set when an error occurred 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. --- diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 5dba391a00..befa611a06 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -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);