]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sink: inform the user when logs will be implicitly truncated
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 22 Jun 2023 15:04:43 +0000 (17:04 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 6 Sep 2023 14:06:39 +0000 (16:06 +0200)
Consider the following example:

 |log ring@test-ring len 2000 local0
 |
 |ring test-ring
 |  maxlen 1000

This would result in emitted logs being silently truncated to 1000 because
test-ring maxlen is smaller than the log directive maxlen.

In this patch we're adding an extra check in post_sink_resolve() to detect
this kind of confusing setups and warn the user about the implicit
truncation when DIAG mode is on.

This commit depends on:
 - "MINOR: sink: simplify post_sink_resolve function"

src/sink.c

index 33824633ed6d5a3f7bbe7f4a9518261573d42124..178afcb8cb8b1e89f48c3d92dbf2082f5e1e198c 100644 (file)
@@ -1305,6 +1305,12 @@ int sink_postresolve_logsrvs(struct list *logsrvs, const char *section, const ch
                                                            logsrv->conf.file, logsrv->conf.line,
                                                            logsrv->ring_name, (unsigned long)ring_max_payload(sink->ctx.ring));
                        }
+                       else if (sink && logsrv->maxlen > sink->maxlen) {
+                               _e_sink_postresolve_logsrvs(ha_diag_warning, "log server", "uses a ring with a smaller maxlen than the one specified on the log directive ('%s' has maxlen = %d), logs will be truncated according to the lowest maxlen between the two.",
+                                                           section, section_name,
+                                                           logsrv->conf.file, logsrv->conf.line,
+                                                           logsrv->ring_name, sink->maxlen);
+                       }
                        logsrv->sink = sink;
                }