From 887382d659b891c94738367024e4e49112029f9a Mon Sep 17 00:00:00 2001 From: Xavier Bauquet Date: Mon, 15 Jun 2020 14:39:11 +0200 Subject: [PATCH] fix(data-planes) access log missing new line With the TrafficLog policy, using a custom format with the `type: file` makes the data-planes concatenate all the Access Logs until a new Log is generated. This bug is not observed when omiting the format. This is fixed by addind a new line after each Access Log. For more informations see #820 --- app/kuma-dp/pkg/dataplane/accesslogs/sender.go | 2 +- pkg/xds/envoy/listeners/access_log_configurer.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/kuma-dp/pkg/dataplane/accesslogs/sender.go b/app/kuma-dp/pkg/dataplane/accesslogs/sender.go index 4cf5feca1b5e..90621d4dea02 100644 --- a/app/kuma-dp/pkg/dataplane/accesslogs/sender.go +++ b/app/kuma-dp/pkg/dataplane/accesslogs/sender.go @@ -30,7 +30,7 @@ func (s *sender) Connect() error { } func (s *sender) Send(record string) error { - _, err := s.conn.Write(append([]byte(record), byte('\n'))) + _, err := s.conn.Write([]byte(record)) return errors.Wrapf(err, "failed to send a log entry to a TCP logging backend: %s", s.address) } diff --git a/pkg/xds/envoy/listeners/access_log_configurer.go b/pkg/xds/envoy/listeners/access_log_configurer.go index 5e00a13f06d6..312b03463450 100644 --- a/pkg/xds/envoy/listeners/access_log_configurer.go +++ b/pkg/xds/envoy/listeners/access_log_configurer.go @@ -46,7 +46,8 @@ func convertLoggingBackend(mesh string, trafficDirection TrafficDirection, sourc if backend.Format != "" { formatString = backend.Format } - format, err := accesslog.ParseFormat(formatString) + + format, err := accesslog.ParseFormat(formatString + "\n") if err != nil { return nil, errors.Wrapf(err, "invalid access log format string: %s", formatString) }