From e9307f0a884d56f69a77e8f95da493243fcdb7a8 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 25 Sep 2023 18:14:31 +0400 Subject: [PATCH] fix: break the watch loop when the watch fails Otherwise the goroutine keeps spinning in the endless loop as `ch` gets closed on error and Stop(). Signed-off-by: Andrey Smirnov --- pkg/client/logs.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/client/logs.go b/pkg/client/logs.go index 9f583439f..6dd19c69a 100644 --- a/pkg/client/logs.go +++ b/pkg/client/logs.go @@ -204,7 +204,11 @@ func watchPodsToStreamLogs(client kubernetes.Interface, cfg *LogConfig, podCh ch go func() { for { - v := <-ch + v, ok := <-ch + if !ok { + break + } + if v.Type == watch.Added && v.Object != nil { switch t := v.Object.(type) { case *v1.Pod: