Hi everyone,

We have just discovered that there is a discrepancy on stderr output
produced by haproxy since version 2.5. This is caused by the command
'add server' and the introduction of the notion of prefix to stderr
output.

When CLI commands are issued after haproxy startup, stderr output may be
produced by commands on stderr. For example with 'enable server':

$ echo "enable server be/srv1" | socat - /usr/local/run/haproxy.stats
* <stderr output>
   "[WARNING]  (4752) : Server be/srv1 is UP/READY (leaving forced 
maintenance)."

We see that the format here is the following one :
   "[loglevel] (pid) : <msg>"

Note that this concerns output on stderr. On CLI, the output is
different with the following message :
   "New server registered."

With dynamic servers support, we have noted that it would be useful to
print internal logs messages both on stderr and on the CLI output. This
is useful for example to notify about a malformed server keyword. With
this, we also have updated stderr output to include a new prefix which
specify the origin of the message. When using 'add server' on the CLI,
prefix is set to "CLI". This has the side effect of cluttering the
output of all following commands with the same "CLI" prefix. What all
this means is that stderr output won't be the same before and after
using 'add server'.

$ echo "add server be/srv1 127.0.0.1:20080" | socat - 
/usr/local/run/haproxy.stats
* <stderr output>
   "[NOTICE]   (4752) : CLI : 'server be/srv1' : New server registered."

$ echo "enable server be/srv1" | socat - /usr/local/run/haproxy.stats
* <stderr output>
   "[WARNING]  (4752) : CLI : Server be/srv1 is UP/READY (leaving forced 
maintenance)."

So this means the stderr format has been changed to :
  "[loglevel] (pid) : <origin> : <msg>"

Note that the output prefix is thread-local. Depending on the thread
which treated the command, the prefix might be set or not. So all this
reveals that stderr output is non predictable since 2.5. Before taking
further actions, we would like to have the feelings of our users about
this, in particular on the following points :

1. Do you monitor haproxy stderr output with scripts which might be
   broken if we change the output format ?

2. Do you find the notion of origin as a prefix on stderr output
   useful ? For now, only "CLI" is used, but it could be extended
   easily, for example to differentiate between CLI and Lua
   interactions.

3. Should we aim to always print stderr logs also on the CLI output ?
   This could be useful to return more details on the cause of success
   or error.

Ideally, we should decide on this before the next 2.7 release.
Thanks everyone for your feedback,

-- 
Amaury Denoyelle

Reply via email to