Skip to content

Commit

Permalink
Use defer to release watch resources for any exit.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed Dec 26, 2023
1 parent 98e0181 commit 2c1a709
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kubegroup/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,12 @@ func (k *kubeClient) watchOnce(out chan<- podAddress, info *podInfo, table map[s
return errWatch
}

defer watcher.Stop()

in := watcher.ResultChan()
for {
select {
case <-done:
watcher.Stop()
k.options.Debugf("%s: done channel closed, exiting", me)
return nil
case event, ok := <-in:
Expand Down

0 comments on commit 2c1a709

Please sign in to comment.