Skip to content

Commit

Permalink
fix: break the watch loop when the watch fails
Browse files Browse the repository at this point in the history
Otherwise the goroutine keeps spinning in the endless loop as `ch` gets
closed on error and Stop().

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Sep 25, 2023
1 parent 1efd8d7 commit e9307f0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/client/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e9307f0

Please sign in to comment.