From 6af282910d29e0ca572ad0c5722498c39f182a95 Mon Sep 17 00:00:00 2001 From: Cyrill Troxler Date: Fri, 18 Oct 2024 08:25:14 +0200 Subject: [PATCH] fix(logcli): create new tail response for every line When tailing with logcli, the loghttp.TailResponse is created outside of the loop, resulting in stale labels within the TailResponse LabelSet as the unmarshal does not clear the map. Fixes #8617 Signed-off-by: Cyrill Troxler --- pkg/logcli/query/tail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/logcli/query/tail.go b/pkg/logcli/query/tail.go index b65e546b904e3..eb95bc848e1de 100644 --- a/pkg/logcli/query/tail.go +++ b/pkg/logcli/query/tail.go @@ -45,10 +45,10 @@ func (q *Query) TailQuery(delayFor time.Duration, c client.Client, out output.Lo log.Println("Print only labels key:", color.RedString(strings.Join(q.ShowLabelsKey, ","))) } - tailResponse := new(loghttp.TailResponse) lastReceivedTimestamp := q.Start for { + tailResponse := new(loghttp.TailResponse) err := unmarshal.ReadTailResponseJSON(tailResponse, conn) if err != nil { // Check if the websocket connection closed unexpectedly. If so, retry.