From a25be06e4df91b3deb97d4268e32f04c16baa71f Mon Sep 17 00:00:00 2001 From: Gustavo Paiva Date: Fri, 18 Oct 2019 22:18:46 -0300 Subject: [PATCH] fix race condition when switching ns. --- internal/watch/no_mx.go | 2 +- internal/watch/pod_mx.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/watch/no_mx.go b/internal/watch/no_mx.go index 6c9539a6..4f4cd708 100644 --- a/internal/watch/no_mx.go +++ b/internal/watch/no_mx.go @@ -112,6 +112,7 @@ func (n *nodeMxWatcher) Run() { for { select { case <-n.doneChan: + close(n.eventChan) return case <-time.After(nodeMXRefresh): list, err := c.MetricsV1beta1().NodeMetricses().List(metav1.ListOptions{}) @@ -127,7 +128,6 @@ func (n *nodeMxWatcher) Run() { func (n *nodeMxWatcher) Stop() { log.Debug().Msg("Stopping NodeMetrix informer!") close(n.doneChan) - close(n.eventChan) } // ResultChan retrieves event channel. diff --git a/internal/watch/pod_mx.go b/internal/watch/pod_mx.go index 2d9d7b51..03a30262 100644 --- a/internal/watch/pod_mx.go +++ b/internal/watch/pod_mx.go @@ -124,6 +124,7 @@ func (p *podMxWatcher) Run() { for { select { case <-p.doneChan: + close(p.eventChan) return case <-time.After(podMXRefresh): list, err := c.MetricsV1beta1().PodMetricses(p.ns).List(metav1.ListOptions{}) @@ -173,7 +174,6 @@ func (p *podMxWatcher) update(list *mv1beta1.PodMetricsList, notify bool) { func (p *podMxWatcher) Stop() { log.Debug().Msg("Stopping PodMetrix informer!!") close(p.doneChan) - close(p.eventChan) } // ResultChan retrieves event channel.