mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: config: report when "monitor fail" rules are misplaced
"monitor-uri" may rely on "monitor fail" rules, which are processed very early, immediately after the HTTP request is parsed and before any http rulesets. It's not reported by the config parser when this ruleset is misplaces, causing some configurations not to work like users would expect. Let's just add the warning for a misplaced rule.
This commit is contained in:
parent
7e351eefe5
commit
721d8e0286
@ -5255,12 +5255,14 @@ monitor-uri <uri>
|
|||||||
version and all headers are ignored, but the request must at least be valid
|
version and all headers are ignored, but the request must at least be valid
|
||||||
at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
|
at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
|
||||||
|
|
||||||
Monitor requests are processed very early. It is not possible to block nor
|
Monitor requests are processed very early, just after the request is parsed
|
||||||
divert them using ACLs. They cannot be logged either, and it is the intended
|
and even before any "http-request" or "block" rulesets. The only rulesets
|
||||||
purpose. They are only used to report HAProxy's health to an upper component,
|
applied before are the tcp-request ones. They cannot be logged either, and it
|
||||||
nothing more. However, it is possible to add any number of conditions using
|
is the intended purpose. They are only used to report HAProxy's health to an
|
||||||
"monitor fail" and ACLs so that the result can be adjusted to whatever check
|
upper component, nothing more. However, it is possible to add any number of
|
||||||
can be imagined (most often the number of available servers in a backend).
|
conditions using "monitor fail" and ACLs so that the result can be adjusted
|
||||||
|
to whatever check can be imagined (most often the number of available servers
|
||||||
|
in a backend).
|
||||||
|
|
||||||
Example :
|
Example :
|
||||||
# Use /haproxy_test to report haproxy's status
|
# Use /haproxy_test to report haproxy's status
|
||||||
|
@ -406,6 +406,19 @@ int warnif_rule_after_tcp_cont(struct proxy *proxy, const char *file, int line,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Report a warning if a rule is placed after a 'monitor fail' rule.
|
||||||
|
* Return 1 if the warning has been emitted, otherwise 0.
|
||||||
|
*/
|
||||||
|
int warnif_rule_after_monitor(struct proxy *proxy, const char *file, int line, const char *arg)
|
||||||
|
{
|
||||||
|
if (!LIST_ISEMPTY(&proxy->mon_fail_cond)) {
|
||||||
|
ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'monitor fail' rule will still be processed before.\n",
|
||||||
|
file, line, arg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Report a warning if a rule is placed after a 'block' rule.
|
/* Report a warning if a rule is placed after a 'block' rule.
|
||||||
* Return 1 if the warning has been emitted, otherwise 0.
|
* Return 1 if the warning has been emitted, otherwise 0.
|
||||||
*/
|
*/
|
||||||
@ -532,13 +545,20 @@ int warnif_misplaced_block(struct proxy *proxy, const char *file, int line, cons
|
|||||||
warnif_misplaced_http_req(proxy, file, line, arg);
|
warnif_misplaced_http_req(proxy, file, line, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* report a warning if a "tcp request content" rule is dangerously placed */
|
/* report a warning if a block rule is dangerously placed */
|
||||||
int warnif_misplaced_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg)
|
int warnif_misplaced_monitor(struct proxy *proxy, const char *file, int line, const char *arg)
|
||||||
{
|
{
|
||||||
return warnif_rule_after_block(proxy, file, line, arg) ||
|
return warnif_rule_after_block(proxy, file, line, arg) ||
|
||||||
warnif_misplaced_block(proxy, file, line, arg);
|
warnif_misplaced_block(proxy, file, line, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* report a warning if a "tcp request content" rule is dangerously placed */
|
||||||
|
int warnif_misplaced_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg)
|
||||||
|
{
|
||||||
|
return warnif_rule_after_monitor(proxy, file, line, arg) ||
|
||||||
|
warnif_misplaced_monitor(proxy, file, line, arg);
|
||||||
|
}
|
||||||
|
|
||||||
/* report a warning if a "tcp request session" rule is dangerously placed */
|
/* report a warning if a "tcp request session" rule is dangerously placed */
|
||||||
int warnif_misplaced_tcp_sess(struct proxy *proxy, const char *file, int line, const char *arg)
|
int warnif_misplaced_tcp_sess(struct proxy *proxy, const char *file, int line, const char *arg)
|
||||||
{
|
{
|
||||||
@ -5807,6 +5827,7 @@ stats_error_parsing:
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err_code |= warnif_misplaced_monitor(curproxy, file, linenum, "monitor fail");
|
||||||
if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) {
|
if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) {
|
||||||
ha_alert("parsing [%s:%d] : error detected while parsing a '%s %s' condition : %s.\n",
|
ha_alert("parsing [%s:%d] : error detected while parsing a '%s %s' condition : %s.\n",
|
||||||
file, linenum, args[0], args[1], errmsg);
|
file, linenum, args[0], args[1], errmsg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user