From 87e7d77e156835c0f88d87b194ac32827e9bd76b Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Fri, 15 May 2020 22:31:45 -0400 Subject: [PATCH] kube-aggregator: Fix goroutine leak --- .../pkg/controllers/status/available_controller.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go index 12b056d70d8..61205ad7d73 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go @@ -321,6 +321,17 @@ func (c *AvailableConditionController) sync(key string) error { // we had trouble with slow dial and DNS responses causing us to wait too long. // we added this as insurance case <-time.After(6 * time.Second): + defer func() { + // errCh needs to have a reader since the above goroutine doing the work + // needs to send to it. This is defered to ensure it runs + // even if the post timeout work itself panics. + go func() { + res := <-errch + if res != nil { + fmt.Error("%v", res) + } + }() + }() results <- fmt.Errorf("timed out waiting for %v", discoveryURL) return }