From bcfd0d1ad1c72c6c3861c8263989f2ce683eee08 Mon Sep 17 00:00:00 2001 From: Cyrill Troxler Date: Fri, 18 Oct 2024 17:12:43 +0200 Subject: [PATCH] fix(logcli): create new tail response for every line (#14525) 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. 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.