Skip to content

Commit c5f73de

Browse files
committed
Converted errch to a buffered channel to avoid goroutine leak
Signed-off-by: Gaurav Singh <[email protected]>
1 parent 0d0af48 commit c5f73de

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (c *AvailableConditionController) sync(key string) error {
287287
}
288288
discoveryURL.Path = "/apis/" + apiService.Spec.Group + "/" + apiService.Spec.Version
289289

290-
errCh := make(chan error)
290+
errCh := make(chan error, 1)
291291
go func() {
292292
// be sure to check a URL that the aggregated API server is required to serve
293293
newReq, err := http.NewRequest("GET", discoveryURL.String(), nil)
@@ -321,13 +321,6 @@ func (c *AvailableConditionController) sync(key string) error {
321321
// we had trouble with slow dial and DNS responses causing us to wait too long.
322322
// we added this as insurance
323323
case <-time.After(6 * time.Second):
324-
// errCh needs to have a reader since the above goroutine doing the work
325-
// needs to send to it.
326-
go func() {
327-
if res := <-errch; res != nil {
328-
fmt.Errorf("timed out response from %v: %v", discoveryURL, res)
329-
}
330-
}()
331324
results <- fmt.Errorf("timed out waiting for %v", discoveryURL)
332325
return
333326
}

0 commit comments

Comments
 (0)