From e4ce26c409e92f6a8e59d157dd8fa3cdee1c49ce Mon Sep 17 00:00:00 2001 From: Jordan Barrett Date: Wed, 2 Aug 2023 12:43:27 +0800 Subject: [PATCH] Flush() is no-op if no logs are buffered --- internals/overlord/logstate/loki.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internals/overlord/logstate/loki.go b/internals/overlord/logstate/loki.go index 03a066d8a..b342b2c96 100644 --- a/internals/overlord/logstate/loki.go +++ b/internals/overlord/logstate/loki.go @@ -67,6 +67,10 @@ func asLokiEntry(entry servicelog.Entry) lokiEntry { } func (c *lokiClient) Flush(ctx context.Context) error { + if c.numEntries() == 0 { + return nil // no-op + } + defer func() { for svc := range c.entries { c.entries[svc] = c.entries[svc][:0]