fix race condition when switching ns.

mine
Gustavo Paiva 2019-10-18 22:18:46 -03:00
parent 10680f993a
commit a25be06e4d
2 changed files with 2 additions and 2 deletions

View File

@ -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.

View File

@ -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.