]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
5 years agoMINOR: threads: export the POSIX thread ID in panic dumps
Willy Tarreau [Fri, 1 May 2020 09:28:49 +0000 (11:28 +0200)] 
MINOR: threads: export the POSIX thread ID in panic dumps

It is very difficult to map a panic dump against a gdb thread dump
because the thread numbers do not match. However gdb provides the
pthread ID but this one is supposed to be opaque and not to be cast
to a scalar.

This patch provides a fnuction, ha_get_pthread_id() which retrieves
the pthread ID of the indicated thread and casts it to an unsigned
long long so as to lose the least possible amount of information from
it. This is done cleanly using a union to maintain alignment so as
long as these IDs are stored on 1..8 bytes they will be properly
reported. This ID is now presented in the panic dumps so it now
becomes possible to map these threads. When threads are disabled,
zero is returned. For example, this is a panic dump:

  Thread 1 is about to kill the process.
  *>Thread 1 : id=0x7fe92b825180 act=0 glob=0 wq=1 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=1 prof=0 harmless=0 wantrdv=0
               cpu_ns: poll=5119122 now=2009446995 diff=2004327873
               curr_task=0xc99bf0 (task) calls=4 last=0
                 fct=0x592440(task_run_applet) ctx=0xca9c50(<CLI>)
               strm=0xc996a0 src=unix fe=GLOBAL be=GLOBAL dst=<CLI>
               rqf=848202 rqa=0 rpf=80048202 rpa=0 sif=EST,200008 sib=EST,204018
               af=(nil),0 csf=0xc9ba40,8200
               ab=0xca9c50,4 csb=(nil),0
               cof=0xbf0e50,1300:PASS(0xc9cee0)/RAW((nil))/unix_stream(20)
               cob=(nil),0:NONE((nil))/NONE((nil))/NONE(0)
               call trace(20):
               |       0x59e4cf [48 83 c4 10 5b 5d 41 5c]: wdt_handler+0xff/0x10c
               | 0x7fe92c170690 [48 c7 c0 0f 00 00 00 0f]: libpthread:+0x13690
               | 0x7ffce29519d9 [48 c1 e2 20 48 09 d0 48]: linux-vdso:+0x9d9
               | 0x7ffce2951d54 [eb d9 f3 90 e9 1c ff ff]: linux-vdso:__vdso_gettimeofday+0x104/0x133
               |       0x57b484 [48 89 e6 48 8d 7c 24 10]: main+0x157114
               |       0x50ee6a [85 c0 75 76 48 8b 55 38]: main+0xeaafa
               |       0x50f69c [48 63 54 24 20 85 c0 0f]: main+0xeb32c
               |       0x59252c [48 c7 c6 d8 ff ff ff 44]: task_run_applet+0xec/0x88c
    Thread 2 : id=0x7fe92b6e6700 act=0 glob=0 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=0 prof=0 harmless=1 wantrdv=0
               cpu_ns: poll=786738 now=1086955 diff=300217
               curr_task=0
    Thread 3 : id=0x7fe92aee5700 act=0 glob=0 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=0 prof=0 harmless=1 wantrdv=0
               cpu_ns: poll=828056 now=1129738 diff=301682
               curr_task=0
    Thread 4 : id=0x7fe92a6e4700 act=0 glob=0 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=0 prof=0 harmless=1 wantrdv=0
               cpu_ns: poll=818900 now=1153551 diff=334651
               curr_task=0

And this is the gdb output:

  (gdb) info thr
    Id   Target Id                         Frame
  * 1    Thread 0x7fe92b825180 (LWP 15234) 0x00007fe92ba81d6b in raise () from /lib64/libc.so.6
    2    Thread 0x7fe92b6e6700 (LWP 15235) 0x00007fe92bb56a56 in epoll_wait () from /lib64/libc.so.6
    3    Thread 0x7fe92a6e4700 (LWP 15237) 0x00007fe92bb56a56 in epoll_wait () from /lib64/libc.so.6
    4    Thread 0x7fe92aee5700 (LWP 15236) 0x00007fe92bb56a56 in epoll_wait () from /lib64/libc.so.6

We can clearly see that while threads 1 and 2 are the same, gdb's
threads 3 and 4 respectively are haproxy's threads 4 and 3.

This may be backported to 2.0 as it removes some confusion in github issues.

5 years agoBUG/MEDIUM: listener: mark the thread as not stuck inside the loop
Willy Tarreau [Fri, 1 May 2020 07:51:11 +0000 (09:51 +0200)] 
BUG/MEDIUM: listener: mark the thread as not stuck inside the loop

We tried hard to make sure we report threads as not stuck at various
crucial places, but one of them is special, it's the listener_accept()
function. The reason it is special is because it will loop a certain
number of times (default: 64) accepting incoming connections, allocating
resources, dispatching them to other threads or running L4 rules on them,
and while all of this is supposed to be extremely fast, when the machine
slows down or runs low on memory, the expectedly small delays in malloc()
caused by contention with other threads can quickly accumulate and suddenly
become critical to the point of triggering the watchdog. Furthermore, it
is technically possible to trigger this by pure configuration by setting
a huge tune.maxaccept value, which should not be possible.

Given that each operation isn't related to the same task but to a different
one each time, it is appropriate to mark the thread as not stuck each time
it accepts new work that possibly gets dispatched to other threads which
execute it.

This looks like this could be a good reason for the issue reported in
issue #388.

This fix must be backported to 2.0.

5 years agoCLEANUP: ssl: silence a build warning when threads are disabled
Willy Tarreau [Fri, 1 May 2020 09:38:39 +0000 (11:38 +0200)] 
CLEANUP: ssl: silence a build warning when threads are disabled

Building without threads now shows this warning:

src/ssl_sock.c: In function 'cli_io_handler_commit_cert':
src/ssl_sock.c:12121:24: warning: unused variable 'bind_conf' [-Wunused-variable]
      struct bind_conf *bind_conf = ckchi->bind_conf;
                        ^~~~~~~~~

This is because the variable is needed only to unlock the structure, and
the unlock operation does nothing in this case. Let's mark the variable
__maybe_unused for this, but it would be convenient in the long term if
we could make the thread macros pretend they consume the argument so that
this remains less visible outside.

No backport is needed.

5 years agoREGTEST: ssl: improve the "set ssl cert" test
William Lallemand [Thu, 30 Apr 2020 08:19:40 +0000 (10:19 +0200)] 
REGTEST: ssl: improve the "set ssl cert" test

Improve the test by removing the curl command and using the same proxy
chaining technique as in commit 3ed722f ("REGTEST: ssl: remove curl from
the "add ssl crt-list" test").

A 3rd request was added which must fail, to ensure that the SNI was
effectively removed from HAProxy.

This patch also adds timeouts in the default section, logs on stderr and
fix some indentation issues.

5 years agoREGTEST: ssl: remove curl from the "add ssl crt-list" test
William Lallemand [Thu, 30 Apr 2020 07:47:08 +0000 (09:47 +0200)] 
REGTEST: ssl: remove curl from the "add ssl crt-list" test

Using curl for SSL tests can be a problem if it wasn't compiled with the
right SSL library and if it didn't share any cipher with HAProxy. To
have more robust tests we now use HAProxy as an SSL client, so we are
sure that the client and the server share the same SSL requirements.

This patch also adds timeouts in the default section, logs on stderr and
fix some indentation issues.

5 years agoREGTEST: http-rules: Require PCRE or PCRE2 option to run map_redirect script
Christopher Faulet [Wed, 29 Apr 2020 12:32:26 +0000 (14:32 +0200)] 
REGTEST: http-rules: Require PCRE or PCRE2 option to run map_redirect script

Only PCRE was specified as required option to execute this script. But PCRE2 is
an valid alternative.

5 years agoDOC: Add more info about request formatting in http-check send description
Christopher Faulet [Wed, 29 Apr 2020 12:20:47 +0000 (14:20 +0200)] 
DOC: Add more info about request formatting in http-check send description

Only one Host header can be defined and some headers are automatically skipped
(Connection, Content-Length and Transfer-Encoding). In addition, a note about
the synchronisation of the Host header value and the request uri has been added.

5 years agoDOC: Fix send rules in the http-check connect example
Christopher Faulet [Wed, 29 Apr 2020 12:19:13 +0000 (14:19 +0200)] 
DOC: Fix send rules in the http-check connect example

Method, uri and version arguments must be explicitly named.

5 years agoCLEANUP: checks: Fix checks includes
Christopher Faulet [Wed, 29 Apr 2020 11:32:21 +0000 (13:32 +0200)] 
CLEANUP: checks: Fix checks includes

5 years agoMINOR: checks: Keep the Host header and the request uri synchronized
Christopher Faulet [Wed, 29 Apr 2020 11:21:37 +0000 (13:21 +0200)] 
MINOR: checks: Keep the Host header and the request uri synchronized

Because in HTTP, the host header and the request authority, if any, must be
identical, we keep both synchornized. It means the right flags are set on the
HTX statrt-line calling http_update_host(). There is no header when it happens,
but it is not an issue. Then, if a Host header is inserted,
http_update_authority() is called.

Note that for now, the host header is not automatically added when required.

5 years agoMINOR: checks: Skip some headers for http-check send rules
Christopher Faulet [Wed, 29 Apr 2020 09:50:01 +0000 (11:50 +0200)] 
MINOR: checks: Skip some headers for http-check send rules

Connection, content-length and transfer-encoding headers are ignored for
http-check send rules. For now, the keep-alive is not supported and the
"connection: close" header is always added to the request. And the
content-length header is automatically added.

5 years agoMINOR: checks: Don't support multiple host header for http-check send rule
Christopher Faulet [Wed, 29 Apr 2020 09:45:44 +0000 (11:45 +0200)] 
MINOR: checks: Don't support multiple host header for http-check send rule

Only one host header definition is supported. There is no reason to define it
several times.

5 years agoMINOR: http-htx: Export functions to update message authority and host
Christopher Faulet [Tue, 28 Apr 2020 17:57:29 +0000 (19:57 +0200)] 
MINOR: http-htx: Export functions to update message authority and host

These functions will be used by HTTP health checks when a request is formatted
before sending it.

5 years agoBUG/MEDIUM: sample: make the CPU and latency sample fetches check for a stream
Willy Tarreau [Wed, 29 Apr 2020 09:59:02 +0000 (11:59 +0200)] 
BUG/MEDIUM: sample: make the CPU and latency sample fetches check for a stream

cpu_calls, cpu_ns_avg, cpu_ns_tot, lat_ns_avg and lat_ns_tot depend on the
stream to find the current task and must check for it or they may cause a
crash if misused or used in a log-format string after commit 5f940703b3
("MINOR: log: Don't depends on a stream to process samples in log-format
string").

This must be backported as far as 1.9.

5 years agoCLEANUP: http: add a few comments on certain functions' assumptions about streams
Willy Tarreau [Wed, 29 Apr 2020 09:52:51 +0000 (11:52 +0200)] 
CLEANUP: http: add a few comments on certain functions' assumptions about streams

get_http_auth() expects a valid stream but this is not mentioned, though
fortunately it's always called from places which already check this.

smp_prefetch_htx() performs all the required checks and is the key to the
stability of almost all sample fetch functions, so let's make this clearer.

5 years agoBUG/MEDIUM: http: the "unique-id" sample fetch could crash without a steeam
Willy Tarreau [Wed, 29 Apr 2020 09:50:38 +0000 (11:50 +0200)] 
BUG/MEDIUM: http: the "unique-id" sample fetch could crash without a steeam

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The unique-id sample fetch function, if called without a stream, will result
in a crash.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.7.

5 years agoBUG/MEDIUM: http: the "http_first_req" sample fetch could crash without a steeam
Willy Tarreau [Wed, 29 Apr 2020 09:52:13 +0000 (11:52 +0200)] 
BUG/MEDIUM: http: the "http_first_req" sample fetch could crash without a steeam

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The http_first_req sample fetch function, if called without a stream, will
result in a crash.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.

5 years agoBUG/MEDIUM: capture: capture.{req,res}.* crash without a stream
Willy Tarreau [Wed, 29 Apr 2020 09:44:54 +0000 (11:44 +0200)] 
BUG/MEDIUM: capture: capture.{req,res}.* crash without a stream

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The capture.req.hdr, capture.res.hdr, capture.req.method, capture.req.uri,
capture.req.ver and capture.res.ver sample fetches used to assume the
presence of a stream, which is not necessarily the case (especially after
the commit above) and would crash haproxy if incorrectly used. Let's make
sure they check for this stream.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.

5 years agoBUG/MEDIUM: capture: capture-req/capture-res converters crash without a stream
Willy Tarreau [Wed, 29 Apr 2020 09:22:08 +0000 (11:22 +0200)] 
BUG/MEDIUM: capture: capture-req/capture-res converters crash without a stream

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The capture-req and capture-res converters were in this case and could
crash the process if misused.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.

5 years agoDOC: give a more accurate description of what check does
Jerome Magnin [Sun, 26 Apr 2020 12:23:04 +0000 (14:23 +0200)] 
DOC: give a more accurate description of what check does

The documentation for check implies that without an application
level check configured, it only enables simple tcp checks. What it
actually does is verify that the configured transport layer is available,
and that optional application level checks succeed.

5 years agoREGTEST: ssl: test the client certificate authentication
William Lallemand [Tue, 28 Apr 2020 19:52:38 +0000 (21:52 +0200)] 
REGTEST: ssl: test the client certificate authentication

This reg-test tests the client auth feature of HAProxy for both the
backend and frontend section with a CRL list.

This reg-test uses 2 chained listeners because vtest does not handle the
SSL. Test the frontend client auth and the backend side at the same
time.

It sends 3 requests: one with a correct certificate, one with an expired
one and one which was revoked. The client then checks if we received the
right one with the right error.

Certificates, CA and CRL are expiring in 2050 so it should be fine for
the CI.

This test could be backported as far as HAProxy 1.6

5 years agoBUG/MEDIUM: mux-h1: make sure we always have a timeout on front connections
Willy Tarreau [Tue, 28 Apr 2020 17:48:41 +0000 (19:48 +0200)] 
BUG/MEDIUM: mux-h1: make sure we always have a timeout on front connections

Mux-h1 currently heavily relies on the presence of an upper stream, even
when waiting for a new request after one is being finished, and it's that
upper stream that's in charge of request and keep-alive timeouts for now.
But since recent commit 493d9dc6ba ("MEDIUM: mux-h1: do not blindly wake
up the tasklet at end of request anymore") that assumption was broken as
the purpose of this change was to avoid initiating processing of a request
when there's no data in the buffer. The side effect is that there's no more
timeout to handle the front connection, resulting in dead front connections
stacking up as clients get kicked off the net.

This fix makes sure we always enable the timeout when there's no stream
attached to the connection. It doesn't do this for back connections since
they may purposely be left idle.

No backport is needed as this bug was introduced in 2.2-dev4.

5 years agoBUG/MINOR: checks: Set the output buffer length before calling parse_binary()
Christopher Faulet [Tue, 28 Apr 2020 14:40:41 +0000 (16:40 +0200)] 
BUG/MINOR: checks: Set the output buffer length before calling parse_binary()

A bug was introduced in the commit 2edcd4cbd ("BUG/MINOR: checks: Avoid
incompatible cast when a binary string is parsed"). The length of the
destination buffer must be set before call the parse_binary() function.

No backport needed.

5 years agoMINOR: log: Add "Tu" timer
Damien Claisse [Tue, 28 Apr 2020 12:09:19 +0000 (12:09 +0000)] 
MINOR: log: Add "Tu" timer

It can be sometimes useful to measure total time of a request as seen
from an end user, including TCP/TLS negotiation, server response time
and transfer time. "Tt" currently provides something close to that, but
it also takes client idle time into account, which is problematic for
keep-alive requests as idle time can be very long. "Ta" is also not
sufficient as it hides TCP/TLS negotiationtime. To improve that, introduce
a "Tu" timer, without idle time and everything else. It roughly estimates
time spent time spent from user point of view (without DNS resolution
time), assuming network latency is the same in both directions.

5 years agoBUG/MINOR: checks: Don't lose warning on proxy capability
Christopher Faulet [Tue, 28 Apr 2020 08:47:28 +0000 (10:47 +0200)] 
BUG/MINOR: checks: Don't lose warning on proxy capability

When a tcp-check line is parsed, a warning may be reported if the keyword is
used for a frontend. The return value must be used to report it. But this info
is lost before the end of the function.

Partly fixes issue #600. No backport needed.

5 years agoBUG/MINOR: checks: Remove bad call to free() when an expect rule is parsed
Christopher Faulet [Tue, 28 Apr 2020 08:42:42 +0000 (10:42 +0200)] 
BUG/MINOR: checks: Remove bad call to free() when an expect rule is parsed

When an error is found during the parsing of an expect rule (tcp or http),
everything is released at the same place, at the end of the function.

Partly fixes issue #600. No backport needed.

5 years agoBUG/MINOR: checks: Avoid incompatible cast when a binary string is parsed
Christopher Faulet [Tue, 28 Apr 2020 08:39:50 +0000 (10:39 +0200)] 
BUG/MINOR: checks: Avoid incompatible cast when a binary string is parsed

parse_binary() function must be called with a pointer on an integer. So don't
pass a pointer on a size_t element, casting it to a pointer on a integer.

Partly fixes issue #600. No backport needed.

5 years agoMINOR: checks: Make the use of the check's server more explicit on connect
Christopher Faulet [Tue, 28 Apr 2020 08:31:53 +0000 (10:31 +0200)] 
MINOR: checks: Make the use of the check's server more explicit on connect

The variable s, pointing on the check server, may be null when a connection is
openned. It happens for email alerts. To avoid ambiguities, its use is now more
explicit. Comments have been added at some places and tests on the variable have
been added elsewhere (useless but explicit).

Partly fixes issue #600.

5 years agoCLEANUP: checks: Remove unused code when ldap server message is parsed
Christopher Faulet [Tue, 28 Apr 2020 08:29:04 +0000 (10:29 +0200)] 
CLEANUP: checks: Remove unused code when ldap server message is parsed

In tcpcheck_ldap_expect_bindrsp(), wait_more_data label cannot be reached.

Partly fixes issue #600.

5 years agoBUG/MINOR: checks: Properly handle truncated mysql server messages
Christopher Faulet [Tue, 28 Apr 2020 08:24:23 +0000 (10:24 +0200)] 
BUG/MINOR: checks: Properly handle truncated mysql server messages

If a message is not fully received from a mysql server, depending on last_read
value, an error must be reported or we must wait for more data. The first if
statement must not check last_read.

Partly fixes issue #600. No backport needed.

5 years agoBUG/MINOR: checks: Remove wrong variable redeclaration
Christopher Faulet [Tue, 28 Apr 2020 07:46:20 +0000 (09:46 +0200)] 
BUG/MINOR: checks: Remove wrong variable redeclaration

When mysql-check option is parsed, the user variable is redeclared without any
reason. thus the redeclared variable is removed.

No backport needed.

5 years agoMINOR: checks: Use ver keyword to specify the HTTP version for http checks
Christopher Faulet [Tue, 28 Apr 2020 07:37:00 +0000 (09:37 +0200)] 
MINOR: checks: Use ver keyword to specify the HTTP version for http checks

'ver' keyword is already used by sample fetches while 'vsn' is not used anywhere
else. So better to use 'ver' too for http-check send rules.

5 years agoMINOR: checks: Support HTTP/2 version (without '.0') for http-check send rules
Christopher Faulet [Tue, 28 Apr 2020 07:10:19 +0000 (09:10 +0200)] 
MINOR: checks: Support HTTP/2 version (without '.0') for http-check send rules

The version is partially parsed to set the flag HTX_SL_F_VER_11 on the HTX
message. But exactly 8 chars is expected. So if "HTTP/2" is specified, the flag
is not set. Thus, the version parsing has been updated to handle "HTTP/2" and
"HTTP/2.0" the same way.

5 years agoCI: cirrus-ci: remove reg-tests/checks/tcp-check-ssl.vtc on CentOS 6
Ilya Shipitsin [Mon, 27 Apr 2020 18:35:13 +0000 (23:35 +0500)] 
CI: cirrus-ci: remove reg-tests/checks/tcp-check-ssl.vtc on CentOS 6

reg-tests/checks/tcp-check-ssl.vtc requires ALPN which is not
available on CentOS 6

5 years agoBUG/MINOR: checks: Fix PostgreSQL regex on the authentication packet
Christopher Faulet [Mon, 27 Apr 2020 16:29:49 +0000 (18:29 +0200)] 
BUG/MINOR: checks: Fix PostgreSQL regex on the authentication packet

For PostgreSQL health check, there is a regex on the backend authentication
packet. It must match to succeed. But it exists 6 types of authentication
packets and the regex only matches the first one (AuthenticationOK). This patch
fixes the regex to match all authentication packets.

No backport needed.

5 years agoBUG/MEDIUM: checks: Destroy the conn-stream before the session
Christopher Faulet [Mon, 27 Apr 2020 13:59:22 +0000 (15:59 +0200)] 
BUG/MEDIUM: checks: Destroy the conn-stream before the session

At the end of a tcp-check based health check, if there is still a connection
attached to the check, it must be closed. But it must be done before releasing
the session, because the session may still be referenced by the mux. For
instance, an h2 stream may still have a reference on the session.

No need to backport.

5 years agoBUG/MEDIUM: sessions: Always pass the mux context as argument to destroy a mux
Christopher Faulet [Mon, 27 Apr 2020 13:53:41 +0000 (15:53 +0200)] 
BUG/MEDIUM: sessions: Always pass the mux context as argument to destroy a mux

This bug was introduced by the commit 2444aa5b ("MEDIUM: sessions: Don't be
responsible for connections anymore."). In session_check_idle_conn(), when the
mux is destroyed, its context must be passed as argument instead of the
connection.

It is de 2.2-dev bug. No need to backport.

5 years agoBUG/MINOR: checks/server: use_ssl member must be signed
Christopher Faulet [Mon, 27 Apr 2020 10:13:06 +0000 (12:13 +0200)] 
BUG/MINOR: checks/server: use_ssl member must be signed

5 years agoBUG/MINOR: checks: Only use ssl_sock_is_ssl() if compiled with SSL support
Christopher Faulet [Mon, 27 Apr 2020 10:06:55 +0000 (12:06 +0200)] 
BUG/MINOR: checks: Only use ssl_sock_is_ssl() if compiled with SSL support

ssl_sock_is_ssl() only exists if HAProxy is complied with SSL support.

No backport needed.

5 years agoBUG/MEDIUM: checks: unsubscribe for events on the old conn-stream on connect
Christopher Faulet [Mon, 27 Apr 2020 09:22:56 +0000 (11:22 +0200)] 
BUG/MEDIUM: checks: unsubscribe for events on the old conn-stream on connect

When a new connection is established, if an old connection is still attached to
the current check, it must be detroyed. When it happens, the old conn-stream
must be used to unsubscribe for events, not the new one.

No backport is needed.

5 years agoBUG/MINOR: server: Fix server_finalize_init() to avoid unused variable
Christopher Faulet [Mon, 27 Apr 2020 09:17:10 +0000 (11:17 +0200)] 
BUG/MINOR: server: Fix server_finalize_init() to avoid unused variable

The variable 'ret' must only be declared When HAProxy is compiled with the SSL
support (more precisely SSL_CTRL_SET_TLSEXT_HOSTNAME must be defined).

No backport needed.

5 years agoREGTEST: Add a script to validate agent checks
Christopher Faulet [Fri, 24 Apr 2020 14:25:28 +0000 (16:25 +0200)] 
REGTEST: Add a script to validate agent checks

5 years agoBUG/MEDIUM: checks: Unsubscribe to mux events when a conn-stream is destroyed
Christopher Faulet [Fri, 24 Apr 2020 14:20:49 +0000 (16:20 +0200)] 
BUG/MEDIUM: checks: Unsubscribe to mux events when a conn-stream is destroyed

Since the tcp-check based heath checks uses the best multuplexer for a
connection, the mux-pt is no longer the only possible choice. So events
subscriptions and unsubscriptions must be done with the mux.

No backport needed.

5 years agoMINOR: checks: Support list of status codes on http-check expect rules
Christopher Faulet [Fri, 24 Apr 2020 11:53:12 +0000 (13:53 +0200)] 
MINOR: checks: Support list of status codes on http-check expect rules

It is now possible to match on a comma-separated list of status codes or range
of codes. In addtion, instead of a string comparison to match the response's
status code, a integer comparison is performed. Here is an example:

  http-check expect status 200,201,300-310

5 years agoBUG/MINOR: mux-fcgi: Be sure to have a connection as session's origin to use it
Christopher Faulet [Fri, 24 Apr 2020 05:19:04 +0000 (07:19 +0200)] 
BUG/MINOR: mux-fcgi: Be sure to have a connection as session's origin to use it

When default parameters are set in a request message, we get the client
connection using the session's origin. But it is not necessarily a
conncection. For instance, for health checks, thanks to recent changes, it may
be a check object. At this step, the client connection may be NULL. Thus, we
must be sure to have a client connection before using it.

This patch must be backported to 2.1.

5 years agoMINOR: checks: Support mux protocol definition for tcp and http health checks
Christopher Faulet [Thu, 23 Apr 2020 14:27:59 +0000 (16:27 +0200)] 
MINOR: checks: Support mux protocol definition for tcp and http health checks

It is now possible to force the mux protocol for a tcp-check based health check
using the server keyword "check-proto". If set, this parameter overwrites the
server one.

In the same way, a "proto" parameter has been added for tcp-check and http-check
connect rules. If set, this mux protocol overwrites all others for the current
connection.

5 years agoBUG/MEDIUM: checks: Use the mux protocol specified on the server line
Christopher Faulet [Thu, 23 Apr 2020 13:50:18 +0000 (15:50 +0200)] 
BUG/MEDIUM: checks: Use the mux protocol specified on the server line

First, when a server health check is initialized, it inherits the mux protocol
from the server if it is not already specified. Because there is no option to
specify the mux protocol for the checks, it is always inherited from the server
for now.

Then, if the connect rule is configured to use the server options, the mux
protocol of the check is used, if defined. Of course, if a mux protocol is
already defined for the connect rule, it is used in priority. But for now, it is
not possible.

Thus, if a server is configured to use, for instance, the h2 protocol, it is
possible to do the same for the health-checks.

No backport needed.

5 years agoDOC: Fix the tcp-check and http-check directives layout
Christopher Faulet [Thu, 23 Apr 2020 13:43:35 +0000 (15:43 +0200)] 
DOC: Fix the tcp-check and http-check directives layout

5 years agoDOC: Add documentation about comments for tcp-check and http-check directives
Christopher Faulet [Thu, 23 Apr 2020 13:22:33 +0000 (15:22 +0200)] 
DOC: Add documentation about comments for tcp-check and http-check directives

The documentation about the comment argument for some tcp-check and http-check
directives was missing. As well as the description of "tcp-check comment" and
"http-check comment" directives.

5 years agoRevert "MEDIUM: checks: capture groups in expect regexes"
Christopher Faulet [Wed, 22 Apr 2020 13:32:11 +0000 (15:32 +0200)] 
Revert "MEDIUM: checks: capture groups in expect regexes"

This reverts commit 1979943c30ef285ed04f07ecf829514de971d9b2.

Captures in comment was only used when a tcp-check expect based on a negative
regex matching failed to eventually report what was captured while it was not
expected. It is a bit far-fetched to be useable IMHO. on-error and on-success
log-format strings are far more usable. For now there is few check sample
fetches (in fact only one...). But it could be really powerful to report info in
logs.

5 years agoREGTEST: Add scripts to test based tcp-check health-checks
Christopher Faulet [Wed, 22 Apr 2020 13:16:58 +0000 (15:16 +0200)] 
REGTEST: Add scripts to test based tcp-check health-checks

These scripts have been added to validate the health-checks based on tcp-check
rules (http, redis, MySQL...).

5 years agoBUG/MINOR: checks: Send the right amount of outgoing data for HTTP checks
Christopher Faulet [Wed, 22 Apr 2020 09:09:25 +0000 (11:09 +0200)] 
BUG/MINOR: checks: Send the right amount of outgoing data for HTTP checks

HTTP health-checks now use HTX multiplexers. So it is important to really send
the amount of outgoing data for such checks because the HTX buffers appears
always full.

No backport needed.

5 years agoMINOR: checks: Use a tree instead of a list to store tcp-check rulesets
Christopher Faulet [Tue, 21 Apr 2020 11:45:00 +0000 (13:45 +0200)] 
MINOR: checks: Use a tree instead of a list to store tcp-check rulesets

Since all tcp-check rulesets are globally stored, it is a problem to use
list. For configuration with many backends, the lookups in list may be costly
and slow downs HAProxy startup. To solve this problem, tcp-check rulesets are
now stored in a tree.

5 years agoBUG/MEDIUM: checks: Be sure to subscribe for sends if outgoing data remains
Christopher Faulet [Tue, 21 Apr 2020 11:02:14 +0000 (13:02 +0200)] 
BUG/MEDIUM: checks: Be sure to subscribe for sends if outgoing data remains

When some data are scheduled to be sent, we must be sure to subscribe for sends
if nothing was sent. Because of a bug, when nothing was sent, connection errors
are checks. If no error is found, we exit, waiting for more data, without any
subcription on send events.

No need to backport.

5 years agoMINOR: checks: Use ist API as far as possible
Christopher Faulet [Tue, 21 Apr 2020 08:57:42 +0000 (10:57 +0200)] 
MINOR: checks: Use ist API as far as possible

Instead of accessing directly to the ist fields, the ist API is used instead. To
get its length or its pointer, to release it or to duplicate it. It is more
readable this way.

5 years agoMINOR: ist: Add a function to retrieve the ist pointer
Christopher Faulet [Tue, 21 Apr 2020 08:46:43 +0000 (10:46 +0200)] 
MINOR: ist: Add a function to retrieve the ist pointer

There is already the istlen() function to get the ist length. Now, it is
possible to call istptr() to get the ist pointer.

5 years agoREGTEST: Fix reg-tests about health-checks to adapt them to recent changes
Christopher Faulet [Mon, 20 Apr 2020 12:59:20 +0000 (14:59 +0200)] 
REGTEST: Fix reg-tests about health-checks to adapt them to recent changes

5 years agoCLEANUP: checks: Reorg checks.c file to be more readable
Christopher Faulet [Mon, 20 Apr 2020 12:54:42 +0000 (14:54 +0200)] 
CLEANUP: checks: Reorg checks.c file to be more readable

The patch is not obvious at the first glance. But it is just a reorg. Functions
have been grouped and ordered in a more logical way. Some structures and flags
are now private to the checks module (so moved from the .h to the .c file).

5 years agoMINOR: checks: Remove unused code about pure TCP checks
Christopher Faulet [Mon, 20 Apr 2020 07:04:37 +0000 (09:04 +0200)] 
MINOR: checks: Remove unused code about pure TCP checks

Thanks to previous change, it is now possible to removed all code handling pure
tcp checks. Now every connection based health-checks are handled by the
tcpcheck_main() function. __event_srv_chk_w() and __event_srv_chk_r() have been
removed. And all connection establishment is handled at one place.

5 years agoMEDIUM: checks: Implement default TCP check using tcp-check rules
Christopher Faulet [Fri, 17 Apr 2020 18:15:59 +0000 (20:15 +0200)] 
MEDIUM: checks: Implement default TCP check using tcp-check rules

Defaut health-checks, without any option, doing only a connection check, are now
based on tcp-checks. An implicit default tcp-check connect rule is used. A
shared tcp-check ruleset, name "*tcp-check" is created to support these checks.

5 years agoMAJOR: checks: Use the best mux depending on the protocol for health checks
Christopher Faulet [Thu, 16 Apr 2020 12:50:06 +0000 (14:50 +0200)] 
MAJOR: checks: Use the best mux depending on the protocol for health checks

When a tcp-check connect rule is evaluated, the mux protocol corresponding to
the health-check is chosen. So for TCP based health-checks, the mux-pt is
used. For HTTP based health-checks, the mux-h1 is used. The connection is marked
as private to be sure to not ruse regular HTTP connection for
health-checks. Connections reuse will be evaluated later.

The functions evaluating HTTP send rules and expect rules have been updated to
be HTX compliant. The main change for users is that HTTP health-checks are now
stricter on the HTTP message format. While before, the HTTP formatting and
parsing were minimalist, now messages should be well formatted.

5 years agoMINOR: connection: Add a function to install a mux for a health-check
Christopher Faulet [Tue, 21 Apr 2020 10:18:05 +0000 (12:18 +0200)] 
MINOR: connection: Add a function to install a mux for a health-check

This function is unused for now. But it will have be used to install a mux for
an outgoing connection openned in a health-check context. In this case, the
session's origin is the check itself, and it is used to know the mode, HTTP or
TCP, depending on the tcp-check type and not the proxy mode. The check is also
used to get the mux protocol if configured.

5 years agoMINOR: checks: Add a mux proto to health-check and tcp-check connect rule
Christopher Faulet [Tue, 21 Apr 2020 09:59:32 +0000 (11:59 +0200)] 
MINOR: checks: Add a mux proto to health-check and tcp-check connect rule

It is not set and not used for now, but it will be possible to force the mux
protocol thanks to this patch. A mux proto field is added to the checks and to
tcp-check connect rules.

5 years agoMINOR: checks: Use the check as origin when a session is created
Christopher Faulet [Tue, 21 Apr 2020 09:53:32 +0000 (11:53 +0200)] 
MINOR: checks: Use the check as origin when a session is created

Before, the server was used as origin during session creation. It was only used
to get the check associated to the server when a variable is get or set in the
check scope or when a check sample fetch was called. So it seems easier to use
the check as origin of a session. It is also more logical becaues the session is
created by the health-check itself and not its server.

5 years agoBUG/MINOR: obj_type: Handle stream object in obj_base_ptr() function
Christopher Faulet [Tue, 21 Apr 2020 09:48:53 +0000 (11:48 +0200)] 
BUG/MINOR: obj_type: Handle stream object in obj_base_ptr() function

The stream object (OBJ_TYPE_STREAM) was missing in the switch statement of the
obj_base_ptr() function.

This patch must be backported as far as 2.0.

5 years agoMINOR: checks/obj_type: Add a new object type for checks
Christopher Faulet [Tue, 21 Apr 2020 09:46:40 +0000 (11:46 +0200)] 
MINOR: checks/obj_type: Add a new object type for checks

An object type is now affected to the check structure.

5 years agoMEDIUM: checks: Refactor how data are received in tcpcheck_main()
Christopher Faulet [Thu, 16 Apr 2020 11:25:58 +0000 (13:25 +0200)] 
MEDIUM: checks: Refactor how data are received in tcpcheck_main()

A dedicated function is now used to received data. fundamentally, it should do
the same operations than before. But the way data are received has been reworked
to be closer to the si_cs_recv() function.

5 years agoMINOR: connection: Add macros to know if a conn or a cs uses an HTX mux
Christopher Faulet [Thu, 16 Apr 2020 08:03:58 +0000 (10:03 +0200)] 
MINOR: connection: Add macros to know if a conn or a cs uses an HTX mux

IS_HTX_CONN() and IS_HTX_CS may now be used to know if a connection or a
conn-stream use an HTX based multiplexer.

5 years agoMINOR: checks: Make resume conditions more explicit in tcpcheck_main()
Christopher Faulet [Thu, 16 Apr 2020 07:52:42 +0000 (09:52 +0200)] 
MINOR: checks: Make resume conditions more explicit in tcpcheck_main()

First tests before executing the loop on tcp-check rules in tcpcheck_main()
function have been slightly modified to be more explicit and easier to
understand.

5 years agoMAJOR: checks: Implement HTTP check using tcp-check rules
Christopher Faulet [Wed, 15 Apr 2020 09:32:03 +0000 (11:32 +0200)] 
MAJOR: checks: Implement HTTP check using tcp-check rules

HTTP health-checks are now internally based on tcp-checks. Of course all the
configuration parsing of the "http-check" keyword and the httpchk option has
been rewritten. But the main changes is that now, as for tcp-check ruleset, it
is possible to perform several send/expect sequences into the same
health-checks. Thus the connect rule is now also available from HTTP checks, jst
like set-var, unset-var and comment rules.

Because the request defined by the "option httpchk" line is used for the first
request only, it is now possible to set the method, the uri and the version on a
"http-check send" line.

5 years agoMINOR: checks: Add a reverse non-comment rule iterator to get last rule
Christopher Faulet [Wed, 15 Apr 2020 09:34:04 +0000 (11:34 +0200)] 
MINOR: checks: Add a reverse non-comment rule iterator to get last rule

the get_last_tcpcheck_rule() function iters on a rule list in the reverse order
and returns the first non comment and non action-kw rule. If no such rule is
found, NULL is returned.

5 years agoMINOR: standard: Add my_memspn and my_memcspn
Christopher Faulet [Wed, 15 Apr 2020 08:23:01 +0000 (10:23 +0200)] 
MINOR: standard: Add my_memspn and my_memcspn

Do the same than strsnp() and strcspn() but on a raw bytes buffer.

5 years agoMINOR: checks: Introduce flags to configure in tcp-check expect rules
Christopher Faulet [Fri, 10 Apr 2020 07:58:42 +0000 (09:58 +0200)] 
MINOR: checks: Introduce flags to configure in tcp-check expect rules

Instead of having 2 independent integers, used as boolean values, to know if the
expect rule is invered and to know if the matching regexp has captures, we know
use a 32-bits bitfield.

5 years agoMINOR: checks: Use an indirect string to represent the expect matching string
Christopher Faulet [Fri, 10 Apr 2020 07:20:02 +0000 (09:20 +0200)] 
MINOR: checks: Use an indirect string to represent the expect matching string

Instead of having a string in the expect union with its length outside of the
union, directly in the expect structure, an indirect string is now used.

5 years agoMEDIUM: checks: Use a shared ruleset to store tcp-check rules
Christopher Faulet [Thu, 9 Apr 2020 21:13:54 +0000 (23:13 +0200)] 
MEDIUM: checks: Use a shared ruleset to store tcp-check rules

All tcp-check rules are now stored in the globla shared list. The ones created
to parse a specific protocol, for instance redis, are already stored in this
list. Now pure tcp-check rules are also stored in it. The ruleset name is
created using the proxy name and its config file and line. tcp-check rules
declared in a defaults section are also stored this way using "defaults" as
proxy name.

For now, all tcp-check ruleset are stored in a list. But it could be a bit slow
to looks for a specific ruleset with a huge number of backends. So, it could be
a good idea to use a tree instead.

5 years agoMINOR: proxy/checks: Register a keyword to parse external-check rules
Christopher Faulet [Thu, 9 Apr 2020 16:12:08 +0000 (18:12 +0200)] 
MINOR: proxy/checks: Register a keyword to parse external-check rules

The keyword 'external-check' is now parsed in a dedicated callback
function. Thus the code to parse these rules is now located in checks.c.

5 years agoMINOR: proxy/checks: Move parsing of external-check option in checks.c
Christopher Faulet [Thu, 9 Apr 2020 13:58:50 +0000 (15:58 +0200)] 
MINOR: proxy/checks: Move parsing of external-check option in checks.c

Parsing of the proxy directive "option external-check" have been moved in checks.c.

5 years agoMINOR: proxy/checks: Register a keyword to parse http-check rules
Christopher Faulet [Thu, 9 Apr 2020 13:54:18 +0000 (15:54 +0200)] 
MINOR: proxy/checks: Register a keyword to parse http-check rules

The keyword 'http-check' is now parsed in a dedicated callback function. Thus
the code to parse these rules is now located in checks.c.

5 years agoMINOR: proxy/checks: Move parsing of tcp-check option in checks.c
Christopher Faulet [Thu, 9 Apr 2020 13:28:16 +0000 (15:28 +0200)] 
MINOR: proxy/checks: Move parsing of tcp-check option in checks.c

Parsing of the proxy directive "option tcp-check" have been moved in checks.c.

5 years agoMINOR: proxy/checks: Move parsing of httpchk option in checks.c
Christopher Faulet [Thu, 9 Apr 2020 12:48:48 +0000 (14:48 +0200)] 
MINOR: proxy/checks: Move parsing of httpchk option in checks.c

Parsing of the proxy directive "option httpchk" have been moved in checks.c.

5 years agoMINOR: checks: Improve log message of tcp-checks on success
Christopher Faulet [Tue, 7 Apr 2020 14:04:38 +0000 (16:04 +0200)] 
MINOR: checks: Improve log message of tcp-checks on success

5 years agoMINOR: checks: Add an option to set success status of tcp-check expect rules
Christopher Faulet [Tue, 7 Apr 2020 12:56:26 +0000 (14:56 +0200)] 
MINOR: checks: Add an option to set success status of tcp-check expect rules

It is now possible to specified the healthcheck status to use on success of a
tcp-check rule, if it is the last evaluated rule. The option "ok-status"
supports "L4OK", "L6OK", "L7OK" and "L7OKC" status.

5 years agoMINOR: Produce tcp-check info message for pure tcp-check rules only
Christopher Faulet [Tue, 7 Apr 2020 10:06:14 +0000 (12:06 +0200)] 
MINOR: Produce tcp-check info message for pure tcp-check rules only

This way, messages reported by protocol checks are closer that the old one.

5 years agoREGTEST: Adapt regtests about checks to recent changes
Christopher Faulet [Tue, 7 Apr 2020 06:00:35 +0000 (08:00 +0200)] 
REGTEST: Adapt regtests about checks to recent changes

5 years agoMEDIUM: checks: Implement agent check using tcp-check rules
Christopher Faulet [Mon, 6 Apr 2020 15:54:24 +0000 (17:54 +0200)] 
MEDIUM: checks: Implement agent check using tcp-check rules

A shared tcp-check ruleset is now created to support agent checks. The following
sequence is used :

    tcp-check send "%[var(check.agent_string)] log-format
    tcp-check expect custom

The custom function to evaluate the expect rule does the same that it was done
to handle agent response when a custom check was used.

5 years agoMINOR: server/checks: Move parsing of server check keywords in checks.c
Christopher Faulet [Mon, 6 Apr 2020 13:04:11 +0000 (15:04 +0200)] 
MINOR: server/checks: Move parsing of server check keywords in checks.c

Parsing of following keywords have been moved in checks.c file : addr, check,
check-send-proxy, check-via-socks4, no-check, no-check-send-proxy, rise, fall,
inter, fastinter, downinter and port.

5 years agoMINOR: server/checks: Move parsing of agent keywords in checks.c
Christopher Faulet [Mon, 6 Apr 2020 12:26:30 +0000 (14:26 +0200)] 
MINOR: server/checks: Move parsing of agent keywords in checks.c

Parsing of following keywords have been moved in checks.c file: agent-addr,
agent-check, agent-inter, agent-port, agent-send and no-agent-check.

5 years agoMEDIUM: checks: Implement SPOP check using tcp-check rules
Christopher Faulet [Sat, 4 Apr 2020 08:27:09 +0000 (10:27 +0200)] 
MEDIUM: checks: Implement SPOP check using tcp-check rules

A share tcp-check ruleset is now created to support SPOP checks. This way no
extra memory is used if several backends use a SPOP check.

The following sequence is used :

    tcp-check send-binary SPOP_REQ
    tcp-check expect custom min-recv 4

The spop request is the result of the function
spoe_prepare_healthcheck_request() and the expect rule relies on a custom
function calling spoe_handle_healthcheck_response().

5 years agoMEDIUM: checks: Implement LDAP check using tcp-check rules
Christopher Faulet [Fri, 3 Apr 2020 21:13:50 +0000 (23:13 +0200)] 
MEDIUM: checks: Implement LDAP check using tcp-check rules

A shared tcp-check ruleset is now created to support LDAP check. This way no
extra memory is used if several backends use a LDAP check.

The following sequance is used :

    tcp-check send-binary "300C020101600702010304008000"

    tcp-check expect rbinary "^30" min-recv 14 \
        on-error "Not LDAPv3 protocol"

    tcp-check expect custom

The last expect rule relies on a custom function to check the LDAP server reply.

5 years agoMEDIUM: checks: Implement MySQL check using tcp-check rules
Christopher Faulet [Thu, 2 Apr 2020 16:07:37 +0000 (18:07 +0200)] 
MEDIUM: checks: Implement MySQL check using tcp-check rules

A share tcp-check ruleset is now created to support MySQL checks. This way no
extra memory is used if several backends use a MySQL check.

One for the following sequence is used :

    ## If no extra params are set
    tcp-check connect default linger
    tcp-check expect custom  ## will test the initial handshake

    ## If the username is defined
    tcp-check connect default linger
    tcp-check send-binary MYSQL_REQ log-format
    tcp-check expect custom  ## will test the initial handshake
    tcp-check expect custom  ## will test the reply to the client message

The log-format hexa string MYSQL_REQ depends on 2 preset variables, the packet
header containing the packet length and the sequence ID (check.header) and the
username (check.username). If is also different if the "post-41" option is set
or not. Expect rules relies on custom functions to check MySQL server packets.

5 years agoMEDIUM: checks: Implement postgres check using tcp-check rules
Christopher Faulet [Thu, 2 Apr 2020 09:44:39 +0000 (11:44 +0200)] 
MEDIUM: checks: Implement postgres check using tcp-check rules

A shared tcp-check ruleset is now created to support postgres check. This way no
extra memory is used if several backends use a pgsql check.

The following sequence is used :

    tcp-check connect default linger

    tcp-check send-binary PGSQL_REQ log-format

    tcp-check expect !rstring "^E" min-recv 5 \
        error-status "L7RSP" on-error "%[check.payload(6,0)]"

    tcp-check expect rbinary "^520000000800000000 min-recv "9" \
        error-status "L7STS" \
        on-success "PostgreSQL server is ok" \
        on-error "PostgreSQL unknown error"

The log-format hexa string PGSQL_REQ depends on 2 preset variables, the packet
length (check.plen) and the username (check.username).

5 years agoMEDIUM: checks: Implement smtp check using tcp-check rules
Christopher Faulet [Wed, 1 Apr 2020 18:54:05 +0000 (20:54 +0200)] 
MEDIUM: checks: Implement smtp check using tcp-check rules

A share tcp-check ruleset is now created to support smtp checks. This way no
extra memory is used if several backends use a smtp check.

The following sequence is used :

    tcp-check connect default linger

    tcp-check expect rstring "^[0-9]{3}[ \r]" min-recv 4 \
        error-status "L7RSP" on-error "%[check.payload(),cut_crlf]"

    tcp-check expect rstring "^2[0-9]{2}[ \r]" min-recv 4 \
        error-status "L7STS" \
        on-error %[check.payload(4,0),ltrim(' '),cut_crlf] \
        status-code "check.payload(0,3)"

    tcp-echeck send "%[var(check.smtp_cmd)]\r\n" log-format

    tcp-check expect rstring "^2[0-9]{2}[- \r]" min-recv 4 \
        error-status "L7STS" \
        on-error %[check.payload(4,0),ltrim(' '),cut_crlf] \
        on-success "%[check.payload(4,0),ltrim(' '),cut_crlf]" \
        status-code "check.payload(0,3)"

The variable check.smtp_cmd is by default the string "HELO localhost" by may be
customized setting <helo> and <domain> parameters on the option smtpchk
line. Note there is a difference with the old smtp check. The server gretting
message is checked before send the HELO/EHLO comand.

5 years agoMEDIUM: checks: Implement ssl-hello check using tcp-check rules
Christopher Faulet [Wed, 1 Apr 2020 09:10:27 +0000 (11:10 +0200)] 
MEDIUM: checks: Implement ssl-hello check using tcp-check rules

A shared tcp-check ruleset is now created to support ssl-hello check. This way
no extra memory is used if several backends use a ssl-hello check.

The following sequence is used :

    tcp-check send-binary SSLV3_CLIENT_HELLO log-format

    tcp-check expect rbinary "^1[56]" min-recv 5 \
        error-status "L6RSP" tout-status "L6TOUT"

SSLV3_CLIENT_HELLO is a log-format hexa string representing a SSLv3 CLIENT HELLO
packet. It is the same than the one used by the old ssl-hello except the sample
expression "%[date(),htonl,hex]" is used to set the date field.

5 years agoMEDIUM: checks: Implement redis check using tcp-check rules
Christopher Faulet [Wed, 1 Apr 2020 09:08:50 +0000 (11:08 +0200)] 
MEDIUM: checks: Implement redis check using tcp-check rules

A share tcp-check ruleset is now created to support redis checks. This way no
extra memory is used if several backends use a redis check.

The following sequence is used :

  tcp-check send "*1\r\n$4\r\nPING\r\n"

  tcp-check expect string "+PONG\r\n" error-status "L7STS" \
      on-error "%[check.payload(),cut_crlf]" on-success "Redis server is ok"

5 years agoMINOR: checks: Support custom functions to eval a tcp-check expect rules
Christopher Faulet [Fri, 3 Apr 2020 13:24:06 +0000 (15:24 +0200)] 
MINOR: checks: Support custom functions to eval a tcp-check expect rules

It is now possible to set a custom function to evaluate a tcp-check expect
rule. It is an internal and not documentd option because the right pointer of
function must be set and it is not possible to express it in the
configuration. It will be used to convert some protocol healthchecks to
tcp-checks.

Custom functions must have the following signature:

  enum tcpcheck_eval_ret (*custom)(struct check *, struct tcpcheck_rule *, int);

5 years agoMINOR: checks: Use dedicated function to handle onsuccess/onerror messages
Christopher Faulet [Fri, 3 Apr 2020 12:51:06 +0000 (14:51 +0200)] 
MINOR: checks: Use dedicated function to handle onsuccess/onerror messages

error and success messages produced when tcp-check healthchecks end are now
handled in dedicated functions.

5 years agoMINOR: checks: Export the tcpcheck_eval_ret enum
Christopher Faulet [Fri, 3 Apr 2020 09:16:13 +0000 (11:16 +0200)] 
MINOR: checks: Export the tcpcheck_eval_ret enum

This enum will be used to define custom function for tcp-check expect rules.

5 years agoMEDIUM: checks: Add a list of vars to set before executing a tpc-check ruleset
Christopher Faulet [Thu, 2 Apr 2020 16:05:11 +0000 (18:05 +0200)] 
MEDIUM: checks: Add a list of vars to set before executing a tpc-check ruleset

A list of variables is now associated to each tcp-check ruleset. It is more a
less a list of set-var expressions. This list may be filled during the
configuration parsing. The listed variables will then be set during each
execution of the tcp-check healthcheck, at the begining, before execution of the
the first tcp-check rule.

This patch is mandatory to convert all protocol checks to tcp-checks. It is a
way to customize shared tcp-check rulesets.

5 years agoMINOR: checks: Relax the default option for tcp-check connect rules
Christopher Faulet [Wed, 1 Apr 2020 14:52:17 +0000 (16:52 +0200)] 
MINOR: checks: Relax the default option for tcp-check connect rules

Now this option may be mixed with other options. This way, options on the server
line are used but may be overridden by tcp-check connect options.

5 years agoMEDIUM: checks: Add status-code sample expression on tcp-check expect rules
Christopher Faulet [Wed, 1 Apr 2020 18:52:31 +0000 (20:52 +0200)] 
MEDIUM: checks: Add status-code sample expression on tcp-check expect rules

This option defines a sample expression, evaluated as an integer, to set the
status code (check->code) if a tcp-check healthcheck ends on the corresponding
expect rule.