Willy Tarreau [Sun, 9 May 2021 08:32:54 +0000 (10:32 +0200)]
BUILD: http_fetch: address a few aliasing warnings with older compilers
gcc-4.4 complains about aliasing in smp_fetch_url_port() and
smp_fetch_url_ip() because the local addr variable is casted to sturct
sockaddr_in before being checked. The family should be checked on the
sockaddr_storage and we have a function to retrieve the port.
The compiler still sees some warnings but these ones are OK now.
Willy Tarreau [Sun, 9 May 2021 08:26:14 +0000 (10:26 +0200)]
MINOR: tools/rnd: compute the result outside of the CAS loop
ha_random64() uses a DWCAS loop to produce the random, but it computes
the resulting value inside the loop while it doesn't change upon success,
so this is a needless overhead inside the critcal path that participates
to making threads fail the race and try again. Let's take the value out
of the loop.
Willy Tarreau [Sun, 9 May 2021 04:47:26 +0000 (06:47 +0200)]
DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments
Some of the Lua doc and a few places still used "Haproxy" or "HAproxy".
There was even one "HA proxy". A few of them were in an example of VTest
output, indicating that VTest ought to be fixed as well. No big deal but
better address all the remaining ones so that these inconsistencies stop
spreading around.
Willy Tarreau [Sun, 9 May 2021 04:45:16 +0000 (06:45 +0200)]
MEDIUM: mailers: use "HAProxy" nor "HAproxy" in the subject of messages
It seems to be the last visible casing inconsistency, but better address
it for completeness otherwise we'll always have to deal with some
exceptions.
Willy Tarreau [Sun, 9 May 2021 04:41:37 +0000 (06:41 +0200)]
ADMIN: netsnmp: report "HAProxy" and not "Haproxy" in output descriptions
In the SNMP fields descriptions, "Haproxy" was mentioned, let's make it
consistent with the rest.
Willy Tarreau [Sun, 9 May 2021 04:38:07 +0000 (06:38 +0200)]
DOC: peers: fix the protocol tag name in the doc
The peers protocol has been using "HAProxyS" as a binary tag sent on the
wire since day one in 1.5-dev3 with commit
2b920a1af ("[MAJOR] Add new
files src/peer.c, include/proto/peers.h and include/types/peers.h for
sync stick table management"), regardless, the doc says the protocol
identifier is "HaproxyS". It is likely this got fixed in the code before
merging and not in the doc.
This should be backported to any release as the doc is wrong.
Willy Tarreau [Sun, 9 May 2021 04:25:16 +0000 (06:25 +0200)]
DOC: remove last occurrences of "HA-Proxy" syntax
There were only a few more used as output examples and comments in a few
docs, it was the right moment to get rid of them. The file intro.txt
which explains how to parse the version also got a hint about the possible
presence of a hyphen in the name in older versions.
Willy Tarreau [Sun, 9 May 2021 04:14:25 +0000 (06:14 +0200)]
MINOR: version: report "HAProxy" not "HA-Proxy" in the version output
When running "haproxy -v", we still get "HA-Proxy" which is the last
place where this confusing oddity happens. Being so used to it I didn't
even notice it until it was reported to me just after 2.2 but it never
got fixed, despite the PRODUCT_NAME macro that is used to report the
name in the stats page and in "show info" being already set to "HAProxy"
15 years ago in 1.2.14 with commit
e03312613. It's about time to
uniformize everything.
Willy Tarreau [Sun, 9 May 2021 04:12:41 +0000 (06:12 +0200)]
REGTESTS: run-regtests: match both "HAProxy" and "HA-Proxy" in the version
The script checks the HAProxy version and was looking for "HA-Proxy" which
is hard-coded in haproxy.c, let's relax the test to also accept "HAProxy".
Daniel Corbett [Sat, 8 May 2021 14:50:37 +0000 (10:50 -0400)]
DOC: Fix a few grammar/spelling issues and casing of HAProxy
This patch fixes a few grammar and spelling issues in configuration.txt.
It was also noted that there was a wide range of case usage
(i.e. haproxy, HAproxy, HAProxy, etc... ). This patch updates them
all to be consistently "HAProxy" except where a binary is mentioned.
Willy Tarreau [Sat, 8 May 2021 21:33:25 +0000 (23:33 +0200)]
BUILD: makefile: reorder object files by build time
This is the per-release reordering to improve build parallelism.
It didn't change much, mostly dns+resolvers inflated this time.
Nowadays build times are mostly dominated by the long dependencies
of include files, no less than 170MB of preprocessed code has to be
built, and half of this is SSL support is disabled. Includes should
likely be reworked to be smaller with less dependencies each,
possibly splitting what's the core of each of them and what is used
to interface with other ones. Each split of a .C file in two adds
0.3s of build time just because of this.
Willy Tarreau [Sat, 8 May 2021 18:25:57 +0000 (20:25 +0200)]
BUILD: config: do not include proxy.h nor errors.h anymore in cfgparse.h
These ones induce a long dependency chain and are not needed anymore.
Willy Tarreau [Sat, 8 May 2021 18:35:03 +0000 (20:35 +0200)]
BUILD: fd: include log.h from fd.c
It's needed for ha_alert() and the header was missing.
Willy Tarreau [Sat, 8 May 2021 18:34:16 +0000 (20:34 +0200)]
BUILD: comp: include proxy.h from flt_http_comp.c
It's used for proxy_type_str() but the header was missing.
Willy Tarreau [Sat, 8 May 2021 18:33:02 +0000 (20:33 +0200)]
BUILD: thread: include log.h from thread.c
It's needed for ha_alert(). Probably that a separate file for error
reporting at boot would be useful.
Willy Tarreau [Sat, 8 May 2021 18:30:37 +0000 (20:30 +0200)]
BUILD: http-rules: include proxy.h from http_rules.c
Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:30:37 +0000 (20:30 +0200)]
BUILD: listener: include proxy.h from listener.c
Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:28:54 +0000 (20:28 +0200)]
BUILD: mux-fcgi: include proxy.h from mux-fcgi.c
proxy_capture_error() was called there without the include, which was
inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:28:54 +0000 (20:28 +0200)]
BUILD: mux-h1: include proxy.h from mux-h1.c
proxy_capture_error() was called there without the include, which was
inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:28:07 +0000 (20:28 +0200)]
BUILD: hlua: include proxy.h from hlua.c
Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:14:39 +0000 (20:14 +0200)]
BUILD: connection: stop including listener-t.h
listener-t comes with openssl just due to the SSL_CTX type that is
declred as a typedef in openssl hence cannot be abstracted at this
level. However connection-t.h doen't need all that just to know that
bind_conf is a struct. Let's declare it with other external types
instead..
Willy Tarreau [Sat, 8 May 2021 18:10:13 +0000 (20:10 +0200)]
MINOR: task: stop including stream.h from task.c
This one comes with a very deep dependency hell, only to know that
process_stream() is a function. Dropping it reduces the preprocessed
output from 1.5MB to 640kB.
Willy Tarreau [Sat, 8 May 2021 18:08:58 +0000 (20:08 +0200)]
BUILD: task: remove unused includes from task.c
freq_ctr.h and time.h are not used, let's drop them.
Willy Tarreau [Sat, 8 May 2021 17:58:37 +0000 (19:58 +0200)]
REORG: config: uninline warnifnotcap() and failifnotcap()
These ones are used by virtually every config parser. Not only they
provide no benefit in being inlined, but they imply a very deep
dependency starting at proxy.h, which results for example in task.c
including openssl.
Let's move these two functions to cfgparse.c.
Willy Tarreau [Sat, 8 May 2021 12:12:47 +0000 (14:12 +0200)]
REORG: stick-table: move composite address functions to stick_table.h
These caddr_* functions were once placed into tools.h in the hope they
would be useful but nobody knows they exist. They could deserve being
moved to their own file with other pointer manipulation functions maybe,
but for now they're the only reason left for stick_table.h to include
tools.h, so let's move them directly there since it's its only user.
This allows to remove tools.h from stick_table.h and slightly reduce
the overall build time.
Willy Tarreau [Sat, 8 May 2021 12:10:42 +0000 (14:10 +0200)]
REORG: stick-table: uninline stktable_alloc_data_type()
This function has no business being inlined in stick_table.h since it's
only used at boot time by the config parser. In addition it causes an
undesired dependency on tools.h because it uses parse_time_err(). Let's
move it to stick_table.c.
Willy Tarreau [Sat, 8 May 2021 12:06:09 +0000 (14:06 +0200)]
BUILD: connection: move list_mux_proto() to connection.c
No idea why this was put inlined into connection.h, it's used only once
for haproxy -vv, and requires tools.h, causing an undesired dependency
from connection.h. Let's move it to connection.c instead where it ought
to have been.
Willy Tarreau [Sat, 8 May 2021 18:23:18 +0000 (20:23 +0200)]
BUILD: fcgi-app: include proxy.h in fcgi-app.c
It's needed for proxies_list and used to be inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:22:17 +0000 (20:22 +0200)]
BUILD: filters: include proxy.h in filters.c
It's needed for proxies_list and used to be inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:21:31 +0000 (20:21 +0200)]
BUILD: mworker: include proxy.h in mworker.c
It's needed for proxies_list and used to be inherited via cfgparse.h.
Willy Tarreau [Sat, 8 May 2021 18:20:21 +0000 (20:20 +0200)]
BUILD: sink: include proxy.h in sink.c
It's needed for proxies_list but was missing.
Willy Tarreau [Sat, 8 May 2021 18:18:59 +0000 (20:18 +0200)]
BUILD: server: include missing proxy.h in server.c
It's needed for a number of functions and definitions but was missing.
Willy Tarreau [Sat, 8 May 2021 12:09:40 +0000 (14:09 +0200)]
BUILD: server: include tools.h from server.c
A lot of functions from tools.h are used there but the file was only
inherited via other ones.
Willy Tarreau [Sat, 8 May 2021 12:08:38 +0000 (14:08 +0200)]
BUILD: stick-table: include freq_ctr.h from stick_table.h
It's needed for update_freq_ctr_period() which is used there.
Willy Tarreau [Sat, 8 May 2021 11:59:56 +0000 (13:59 +0200)]
BUILD: udp: include tools.h from proto_udp.c
A few functions are used from there for address conversion but the
file wasn't included.
Willy Tarreau [Sat, 8 May 2021 11:59:05 +0000 (13:59 +0200)]
BUILD: queue: include tools.h from queue.c
It uses memprintf() without including the file because it inherited
it from other ones.
Willy Tarreau [Sat, 8 May 2021 11:58:19 +0000 (13:58 +0200)]
BUILD: mworker: include tools.h from mworker.c
It needs it for memprintf() but didn't include the file.
Willy Tarreau [Sat, 8 May 2021 11:57:19 +0000 (13:57 +0200)]
BUILD: compression: include tools.h in compression.c
It needs it for memprintf() but it wasn't included.
Willy Tarreau [Sat, 8 May 2021 11:56:31 +0000 (13:56 +0200)]
BUILD: vars: include tools.h in vars.c
A number of functions from tools.h are used there but the file was not
included.
Willy Tarreau [Sat, 8 May 2021 11:55:40 +0000 (13:55 +0200)]
BUILD: payload: include tools.h in payload.c
It needs it for memprintf() but used to inherit it via other include files.
Willy Tarreau [Sat, 8 May 2021 11:09:46 +0000 (13:09 +0200)]
BUILD: dns: include tools.h in dns.c
It is used for get_addr_len() without being included. It could be worth
splitting address manipulation functions to a different set of files.
Willy Tarreau [Sat, 8 May 2021 11:08:34 +0000 (13:08 +0200)]
BUILD: server-state: include tools.h from server_state.c
Many functions from tools.h are called there without the file being
included.
Willy Tarreau [Sat, 8 May 2021 11:07:31 +0000 (13:07 +0200)]
BUILD: connection: include tools.h in connection.c
Several functions from tools.h are called there without the file being
included.
Willy Tarreau [Sat, 8 May 2021 11:05:30 +0000 (13:05 +0200)]
BUILD: sink: include tools.h in sink.c
Several functions from tools.h are used in sink.c without tools.h being
included.
Willy Tarreau [Sat, 8 May 2021 11:03:55 +0000 (13:03 +0200)]
BUILD: cache: include tools.h in cache.c
cache.c uses a lot of functions from tools.h without including it.
Willy Tarreau [Sat, 8 May 2021 11:03:04 +0000 (13:03 +0200)]
BUILD: session: include tools.h in session.c
The file session.c calls plenty of functions from tools.h but did not
include it.
Willy Tarreau [Sat, 8 May 2021 11:02:07 +0000 (13:02 +0200)]
BUILD: proxy: include tools.h in proxy.c
Many functions are used from tools.h but the file wasn't included and
was inherited through others.
Willy Tarreau [Sat, 8 May 2021 11:01:23 +0000 (13:01 +0200)]
BUILD: htx: include tools.h in http_htx.c
Several functions from tools.h are called there and it used to be
inherited through others.
Willy Tarreau [Sat, 8 May 2021 11:00:23 +0000 (13:00 +0200)]
BUILD: config: include tools.h in cfgparse-listen.c
Many functions defined in tools.h were called there but the file used
to be inherited via others.
Willy Tarreau [Sat, 8 May 2021 10:59:47 +0000 (12:59 +0200)]
BUILD: resolvers: include tools.h
Many functions from tools.h are called there but it was inherited via others.
Willy Tarreau [Sat, 8 May 2021 10:58:12 +0000 (12:58 +0200)]
BUILD: promex: service-prometheus.c needs tools.h
It calls url_decode() and memprintf() but used to inherit them through
others.
Willy Tarreau [Sat, 8 May 2021 10:57:17 +0000 (12:57 +0200)]
BUILD: spoe: flt_spoe.c needs tools.h
It uses many functions declared there but used to inherit it through others.
Willy Tarreau [Sat, 8 May 2021 10:56:20 +0000 (12:56 +0200)]
BUILD: wurfl: wurfl.c needs tools.h
It calls memprintf() which is defined there but used to inherit it
through others.
Willy Tarreau [Sat, 8 May 2021 10:54:42 +0000 (12:54 +0200)]
BUILD: config: cfgparse-ssl.c needs tools.h
It calls parse_time_err() which is defined there but used to inherit it
through others.
Willy Tarreau [Sat, 8 May 2021 10:52:56 +0000 (12:52 +0200)]
BUILD: ssl: ssl_utils requires chunk.h
It uses chunk_printf() so it needs it. Currently it gets it through
others.
Willy Tarreau [Sat, 8 May 2021 10:30:50 +0000 (12:30 +0200)]
REORG: mworker: move proc_self from global to mworker
Only mworker uses proc_self, and it was declared in global.h, forcing
users of global.h to include mworker and its dependencies.
Moving it to mworker reduces the preprocessed size of version.c from
170 to 125kB by shrinking the number of local includes from 30 to 16
and the number of system includes from 147 to 132.
Willy Tarreau [Sat, 8 May 2021 10:29:51 +0000 (12:29 +0200)]
BUILD: auth: include missing list.h
list_for_each_entry() requires list.h but used to inherit it by accident
through global.h and mworker-t.h. Let's explicitly add it.
Willy Tarreau [Sat, 8 May 2021 10:27:42 +0000 (12:27 +0200)]
BUILD: wdt: include signal-t.h
WDT_SIG is used there, thus signal-t.h is required. Currently it's
retrieved by accident through global.h.
Willy Tarreau [Sat, 8 May 2021 10:26:10 +0000 (12:26 +0200)]
REORG: threads: move all_thread_mask() to thread.h
It was declared in global.h, forcing plenty of source files to include
it only for this while it's only based on definitions from thread.h.
Willy Tarreau [Sat, 8 May 2021 09:41:28 +0000 (11:41 +0200)]
REORG: vars: move the "proc" scope variables out of the global struct
The presence of this field causes a long dependency chain because almost
everyone includes global-t.h, and vars include sample_data which include
some system includes as well as HTTP parts.
There is absolutely no reason for having the process-wide variables in
the global struct, let's just move them into vars.c and vars.h. This
reduces from ~190k to ~170k the preprocessed output of version.c.
Willy Tarreau [Sat, 8 May 2021 09:06:32 +0000 (11:06 +0200)]
MINOR: config: mark tune.fd.edge-triggered as experimental
This one is stated as experimental in the doc but could still be used
by accidental copy-paste. Let's mark it with KWF_EXPERIMENTAL so that
users have to opt-in to use it.
Willy Tarreau [Sat, 8 May 2021 06:14:04 +0000 (08:14 +0200)]
MINOR: stats: make "show info" able to report rates as floats when asked
Now "show info float" will also report SSL rates, connection rates and
key reuse ratios as floats. This can be convenient at very low rates.
Note that the SSL reuse ratio which used to commonly oscillate between
0 and 1 under load is now more often above zero with small values. It
indicates that for better stability we shouldn't be comparing a key rate
with a connection rate but instead we should measure the reuse rate at
its source.
Willy Tarreau [Sat, 8 May 2021 05:56:56 +0000 (07:56 +0200)]
MINOR: stats: report uptime and start time as floats with subsecond resolution
When "show info float" is used, the uptime and start time will be reported
with subsecond resolution (microsecond actually since timeval is used).
Willy Tarreau [Sat, 8 May 2021 05:40:52 +0000 (07:40 +0200)]
MINOR: stats: use tv_remain() to precisely compute the uptime
We'll have to support reporting sub-second uptimes, so let's use the
appropriate function which will automatically adjust the tv_usec field.
In addition to this, it will also report a more accurate uptime thanks
to considering the sub-second part in the result.
Willy Tarreau [Sat, 8 May 2021 05:54:24 +0000 (07:54 +0200)]
MINOR: stats: support an optional "float" option to "show info"
This will allow some fields to be produced with a higher accuracy when
the requester indicates being able to parse floats. Rates and times are
among the elements which can make sense.
Willy Tarreau [Sat, 8 May 2021 05:43:53 +0000 (07:43 +0200)]
MINOR: stats: pass the appctx flags to stats_fill_info()
Currently the stats filling function knows nothing about the caller's
needs, so let's pass the STAT_* flags so that it can adapt to the
requester's constraints.
Willy Tarreau [Sat, 8 May 2021 05:37:38 +0000 (07:37 +0200)]
MINOR: stats: add the HTML conversion for float types
For the prometheus exporter, a new float type was added for the fields
and its conversion was added everywhere except for the HTML output.
Now that we have F2H() we can implement it for consistency.
Willy Tarreau [Sat, 8 May 2021 08:38:20 +0000 (10:38 +0200)]
MINOR: stats: avoid excessive padding of float values with trailing zeroes
When emitting stats, we don't need to have 6 zeroes after the decimal point
for each value, so let's trim floating point numbers to the longest needed
only.
Willy Tarreau [Sat, 8 May 2021 06:12:37 +0000 (08:12 +0200)]
MINOR: freq_ctr: add new functions to report float measurements
For stats reporting it can be convenient to report floats at low rates
instead of discrete integers. We do have quite some precision since we
currently divide counters by number of milliseconds, so we can usually
add 3 digits after the decimal point.
Willy Tarreau [Sat, 8 May 2021 05:35:00 +0000 (07:35 +0200)]
MINOR: tools: add a float-to-ascii conversion function
We already had ultoa_r() and friends but nothing to emit inline floats.
This is now done with ftoa_r() and F2A/F2H. Note that the latter both use
the itoa_str[] as temporary storage and that the HTML format currently is
the exact same as the ASCII one. The trailing zeroes are always timmed so
these outputs are usable in user-visible output.
Willy Tarreau [Sat, 8 May 2021 08:28:53 +0000 (10:28 +0200)]
MINOR: tools: implement trimming of floating point numbers
When using "%f" to print a float, it automatically gets 6 digits after
the decimal point and there's no way to automatically adjust to the
required ones by dropping trailing zeroes. This function does exactly
this and automatically drops the decimal point if all digits after it
were zeroes. This will make numbers more friendly in stats and makes
outputs shorter (e.g. JSON where everything is just a "number").
The function is designed to be easy to use with snprint() and chunks:
snprintf:
flt_trim(buf, 0, snprintf(buf, sizeof(buf), "%f", x));
chunk_printf:
out->data = flt_trim(out->area, 0, chunk_printf(out, "%f", x));
chunk_appendf:
size_t prev_data = out->data;
out->data = flt_trim(out->area, prev_data, chunk_appendf(out, "%f", x));
Willy Tarreau [Sat, 8 May 2021 05:46:44 +0000 (07:46 +0200)]
DOC: management: mention that some fields may be emitted as floats
Floats in stats output are currently not emitted but are technically
possible, so let's mention that.
Willy Tarreau [Sat, 8 May 2021 04:50:28 +0000 (06:50 +0200)]
MINOR: sample: improve error reporting on missing arg to strcmp() converter
Calling the strcmp() converter with no argument yields this strange error:
[ALERT] (31439) : parsing [test.cfg:3] : error detected in frontend 'f' while parsing 'http-request redirect' rule : failed to parse sample expression <src,strcmp]> : invalid args in converter 'strcmp' : failed to register variable name ''.
This is because the vars name check tries to see if it can create such a
variable having an empty name. Let's at least make a special case of the
missing argument. Now we can read a more explicit:
[ALERT] (31655) : parsing [test.cfg:3] : error detected in frontend 'f' while parsing 'http-request redirect' rule : failed to parse sample expression <src,strcmp]> : invalid args in converter 'strcmp' : missing variable name.
This was done for secure_strcmp() as well.
Remi Tricot-Le Breton [Tue, 4 May 2021 10:22:34 +0000 (12:22 +0200)]
DOC: ssl: Add information about crl-file option
When using the crl-file option with multiple Certificate Authority
levels in the CA chain, there must be one CRL per CA or the verify
function on the backend side will raise an "unagle to get certificate
CRL" error (error code 3).
This was required by GitHub issue #1201.
Willy Tarreau [Fri, 7 May 2021 14:46:52 +0000 (16:46 +0200)]
ADDONS: make addons/ discoverable by git via .gitignore
When the contrib/ parts were moved to addons/, no rule was added in
.gitignore to make addons/ searchable for new files, let's fix it.
Remi Tricot-Le Breton [Fri, 7 May 2021 13:28:08 +0000 (15:28 +0200)]
DOC: ssl: Extra files loading now works for backends too
When implementing the server side certificate hot update, the ckch
mechanism was used on the backend side in order to mimic the frontend
certificate management and to enable server line certificate update via
the CLI (see GitHub issue #427). As an unexpected side effect, we now
also look for ssl extra files (cert.pem.key, cert.pem.ocsp ...) for the
backend side.
This patch updates the documentation accordingly.
This answers to GitHub issue #845.
Amaury Denoyelle [Fri, 7 May 2021 13:13:51 +0000 (15:13 +0200)]
BUG/MINOR: server: do not report diag for peer servers with null weight
Only check servers attached to a proxy with PR_CAP_LB.
This does not need to be backported as the diag message was added in the
current 2.4-dev branch.
Amaury Denoyelle [Fri, 7 May 2021 13:12:20 +0000 (15:12 +0200)]
MINOR: proxy: define PR_CAP_LB
Add a new proxy capability for proxy with load-balancing capabilities.
This help to differentiate listen/frontend/backend with special proxies
such as peer proxies.
Amaury Denoyelle [Fri, 7 May 2021 13:07:21 +0000 (15:07 +0200)]
BUILD: fix usage of ha_alert without format string
The compilation is failing due to no format string used in ha_alert.
This does not need to be backported.
Amaury Denoyelle [Thu, 6 May 2021 13:50:12 +0000 (15:50 +0200)]
MINOR: http_act: mark normalize-uri as experimental
normalize-uri http rule is marked as experimental, so it cannot be
activated without the global 'expose-experimental-directives'. The
associated vtc is updated to be able to use it.
Amaury Denoyelle [Wed, 5 May 2021 15:09:12 +0000 (17:09 +0200)]
MINOR: stats: report tainted on show info
Add a new info field ST_F_TAINTED to dump tainted status at the end of
the 'show info' output.
Amaury Denoyelle [Wed, 5 May 2021 14:29:23 +0000 (16:29 +0200)]
MINOR: cli: set tainted when using CLI expert/experimental mode
Mark the process as tainted as soon as a command command only accessible
in expert or experimental mode is executed.
Amaury Denoyelle [Fri, 7 May 2021 12:25:01 +0000 (14:25 +0200)]
MINOR: action: implement experimental actions
Support experimental actions. It is mandatory to use
'expose-experimental-directives' before to be able to use them.
If such action is present in the config file, the tainted status of the
process is updated. Another tainted status is set when an experimental
action is executed.
Amaury Denoyelle [Thu, 6 May 2021 13:33:09 +0000 (15:33 +0200)]
MINOR: action: replace match_pfx by a keyword flags field
Define a new keyword flag KWF_MATCH_PREFIX. This is used to replace the
match_pfx field of action struct.
This has the benefit to have more explicit action declaration, and now
it is possible to quickly implement experimental actions.
Amaury Denoyelle [Thu, 6 May 2021 14:21:39 +0000 (16:21 +0200)]
MINOR: cfgparse: implement experimental config keywords
Add a new flag to mark a keyword as experimental. An experimental
keyword cannot be used if the global 'expose-experimental-directives' is
not present first.
Only keywords parsed through a standard cfg_keywords lists in
global/proxies section will be automatically detected if declared
experimental. To support a keyword outside of these lists,
check_kw_experimental must be called manually during its parsing.
If an experimental keyword is present in the config, the tainted flag is
updated.
For the moment, no keyword is marked as experimental.
Amaury Denoyelle [Thu, 6 May 2021 15:33:29 +0000 (17:33 +0200)]
MINOR: cfgparse: add a new field flags in cfg_keyword
This field will be used to add various mechanism to config parsing.
Currently no flag value is implemented. The following commit will
implement experimental keywords.
Amaury Denoyelle [Wed, 5 May 2021 14:18:45 +0000 (16:18 +0200)]
MINOR: global: define tainted flag
Add a global flag named 'tainted'. Its purpose is to report various
status about experimental features used for the current process
lifetime.
By default it is initialized to 0. It can be set/retrieve by a couple of
new functions mark_tainted()/get_tainted(). Once a flag is set, it
cannot be resetted.
Currently, no tainted status is implemented, it will be the subject of
the following commits.
Christopher Faulet [Fri, 7 May 2021 09:45:26 +0000 (11:45 +0200)]
BUG/MINOR: checks: Reschedule check on observe mode only if fastinter is set
On observe mode, if a server is marked as DOWN, the server's health-check is
rescheduled using the fastinter timeout if the new expiration date is newer
that the current one. But this must only be performed if the fastinter
timeout is defined.
Internally, tick_is_lt() function only checks the date and does not perform any
verification on the provided args. Thus, we must take care of it. However, it is
possible to disable the server health-check by setting its task expiration date
to TICK_ETERNITY.
This patch must be backported as far as 2.2. It is related to
Christopher Faulet [Thu, 6 May 2021 14:01:18 +0000 (16:01 +0200)]
BUG/MINOR: checks: Handle synchronous connect when a tcpcheck is started
A connection may be synchronously established. In the tcpcheck context, it
may be a problem if several connections come one after another. In this
case, there is no event to close the very first connection before starting
the next one. The checks is thus blocked and timed out, a L7 timeout error
is reported.
To fix the bug, when a tcpcheck is started, we immediately evaluate its
state. Most of time, nothing is performed and we must wait. But it is thus
possible to handle the result of a successfull connection.
This patch should fix the issue #1234. It must be backported as far as 2.2.
Christopher Faulet [Wed, 5 May 2021 19:05:09 +0000 (21:05 +0200)]
BUG/MINOR: stream: Reset stream final state and si error type on L7 retry
Thanks to a previous fix, the stream error mask is now cleared on L7
retry. But the stream final state (SF_FINST_*) and the stream-interface
error type must also be reset to properly restart a new connection and be
sure to not inherit errors from the previous connection attempt.
In addition, SF_ADDR_SET flag is not systematically removed.
stream_choose_redispatch() already takes care to unset it if necessary. When
the connection is not redispatch, the server address can be preserved.
This patch must be backported as far as 2.0.
Willy Tarreau [Fri, 7 May 2021 09:38:37 +0000 (11:38 +0200)]
CLEANUP: cli/tree-wide: properly re-align the CLI commands' help messages
There were 102 CLI commands whose help were zig-zagging all along the dump
making them unreadable. This patch realigns all these messages so that the
command now uses up to 40 characters before the delimiting colon. About a
third of the commands did not correctly list their arguments which were
added after the first version, so they were all updated. Some abuses of
the term "id" were fixed to use a more explanatory term. The
"set ssl ocsp-response" command was not listed because it lacked a help
message, this was fixed as well. The deprecated enable/disable commands
for agent/health/server were prominently written as deprecated. Whenever
possible, clearer explanations were provided.
Willy Tarreau [Fri, 7 May 2021 06:59:50 +0000 (08:59 +0200)]
MINOR: config: add a new message directive: .diag
This one works just like .notice/.warning/.alert except that it prints
the message at level "DIAG" only when haproxy runs in diagnostic mode
(-dD). This can be convenient for example to pass a few hints to help
locate certain config parts or to leave messages about certain temporary
workarounds.
Example:
.diag "WTA/2021-05-07: $.LINE: replace 'redirect' with 'return' after final switch to 2.4"
http-request redirect location /goaway if ABUSE
Willy Tarreau [Fri, 7 May 2021 06:42:39 +0000 (08:42 +0200)]
MEDIUM: log: slightly refine the output format of alerts/warnings/etc
For about 20 years we've been emitting cryptic messages on warnings and
alerts, that nobody knows how to parse:
[NOTICE] 126/080118 (3115) : haproxy version is 2.4-dev18-0b7c78-49
[NOTICE] 126/080118 (3115) : path to executable is ./haproxy
[WARNING] 126/080119 (3115) : Server default/srv1 is DOWN via static/srv1. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 126/080119 (3115) : backend 'default' has no server available!
Hint: the first 3-digit number is the day of year, and the 6 digits
after it represent the time of day in format HHMMSS, then the pid in
parenthesis. These are not quite user-friendly and such cryptic into
are not useful at all.
This patch slightly adjusts the output by performing these minimal changes:
- removing the date/time, as they were added very early when haproxy
was meant to be used in foreground as a debugging tool, and they're
provided in more details in logs nowadays ;
- better aligning the fields by padding the severity tag to 10 chars.
The diag output was renamed to "DIAG" only.
Now the output provides this:
[NOTICE] (4563) : haproxy version is 2.4-dev18-75a428-51
[NOTICE] (4563) : path to executable is ./haproxy
[WARNING] (4563) : Server default/srv1 is DOWN via static/srv1. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] (4563) : backend 'default' has no server available!
The useless space before the colon was kept so as not to confuse any
possible output parser.
The few entries in the doc referring to this format were adjusted to
reflect the new one.
The change was tagged "MEDIUM" as it may have visible consequences on
home-grown monitoring tools, though it is extremely unlikely due to the
limited extent of these changes.
Willy Tarreau [Fri, 7 May 2021 06:19:30 +0000 (08:19 +0200)]
BUG/MINOR: stream: properly clear the previous error mask on L7 retries
The cleanup of the previous error was incorrect on L7 retries, it would
OR two values while they're part of an enum, leaving some bits set.
Depending on the errors it was possible to occasionally see an internal
error ("I" flag) being logged.
This should be backported as far as 2.0, though the do_l7_retry() function
in in proto_htx.c in older versions.
Willy Tarreau [Fri, 7 May 2021 06:01:35 +0000 (08:01 +0200)]
BUG/MINOR: activity: use the new pointer to calculate the new size in realloc()
When memory profiling is enabled, realloc() can occasionally get the area
size wrong due to the wrong pointer being used to check the new size. When
the old area gets unmapped in the operation, this may even result in a
crash. There's no impact without memory profiling though.
No backport is needed as this is exclusively 2.4-dev.
Willy Tarreau [Thu, 6 May 2021 14:53:26 +0000 (16:53 +0200)]
MINOR: config: add predicates "version_atleast" and "version_before" to cond blocks
These predicates respectively verify that the current version is at least
a given version or is before a specific one. The syntax is exactly the one
reported by "haproxy -v", though each component is optional, so both "1.5"
and "2.4-dev18-88910-48" are supported. Missing components equal zero, and
"dev" is below "pre" or "rc", which are both inferior to no such mention
(i.e. they are negative). Thus "2.4-dev18" is older than "2.4-rc1" which
is older than "2.4".
Willy Tarreau [Thu, 6 May 2021 14:34:23 +0000 (16:34 +0200)]
MINOR: config: add predicate "feature" to detect certain built-in features
The "feature(name)" predicate will return true if <name> corresponds to
a name listed after a '+' in the features list, that is it was enabled at
build time with USE_<name>=1. Typical use cases will include OPENSSL, LUA
and LINUX_SPLICE. But maybe it will also be convenient to use with optional
addons such as PROMEX and the device detection modules to help keeping the
same configs across various deployments.
Willy Tarreau [Thu, 6 May 2021 14:10:09 +0000 (16:10 +0200)]
MINOR: config: add predicates "streq()" and "strneq()" to conditional expressions
"streq(str1,str2)" will return true if the two strings match while
"strneq(str1,str2)" will return true only if they differ. This is
convenient to match an environment variable against a predefined value.
Willy Tarreau [Thu, 6 May 2021 13:55:14 +0000 (15:55 +0200)]
MINOR: config: add predicate "defined()" to conditional expression blocks
"defined(name)" will return true if <name> is a defined environment variable
otherwise false, regardless of its contents.
Willy Tarreau [Thu, 6 May 2021 13:49:04 +0000 (15:49 +0200)]
MINOR: config: make cfg_eval_condition() support predicates with arguments
Now we can look up a list of known predicates and pre-parse their
arguments. For now the list is empty. The code needed to be arranged with
a common exit point to release all arguments because there's no default
argument freeing function (it likely only used to exist in the deinit
code). Since we only support simple arguments for now it's no big deal,
only a 2-liner loop.