Skip to content

Commit

Permalink
fix: send on close channel
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-lucky committed Nov 27, 2024
1 parent eea8b07 commit 6bbe8ab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/registry/hpaaggregator/aggregation/forward/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,25 @@ func (p *PodREST) Watch(ctx context.Context, options *metainternalversion.ListOp
case event, ok := <-watcher.ResultChan():
if !ok {
lock.Lock()
defer lock.Unlock()

if !isProxyChClosed {
close(proxyCh)
isProxyChClosed = true
logger.WithValues("cluster", cluster).Info("Closed proxy watcher channel")
}
lock.Unlock()

Check warning on line 195 in pkg/registry/hpaaggregator/aggregation/forward/pod.go

View check run for this annotation

Codecov / codecov/patch

pkg/registry/hpaaggregator/aggregation/forward/pod.go#L194-L195

Added lines #L194 - L195 were not covered by tests
return
}
if pod, ok := event.Object.(*corev1.Pod); ok {
clusterobject.MakePodUnique(pod, cluster)
event.Object = pod
}
proxyCh <- event

lock.Lock()
if !isProxyChClosed {
proxyCh <- event
}
lock.Unlock()

Check warning on line 207 in pkg/registry/hpaaggregator/aggregation/forward/pod.go

View check run for this annotation

Codecov / codecov/patch

pkg/registry/hpaaggregator/aggregation/forward/pod.go#L203-L207

Added lines #L203 - L207 were not covered by tests
}
}
}(clusters[i].Name)
Expand Down

0 comments on commit 6bbe8ab

Please sign in to comment.