kubernetes-sigs / controller-runtime

Repo for the controller-runtime subproject of kubebuilder (sig-apimachinery)
Apache License 2.0
2.56k stars 1.15k forks source link

[BUG]: goroutine leak when `leaderelection.NewLeaderElector` return error #2834

Open alpha-baby opened 5 months ago

alpha-baby commented 5 months ago

https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/manager/internal.go#L602

leak here : https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/manager/internal.go#L519

When I was using controller-runtime v0.14.6 and configured an incorrect RenewDeadline setting, it caused an error with leaderelection.NewLeaderElector. Consequently, the following goroutine was continuously blocked:

1 @ 0x100a4f5a8 0x100a1793c 0x100a17664 0x1024ffeec 0x1024ffb78 0x1024ff320 0x1024ff12c 0x1025b51c0 0x100a80874
#   0x1024ffeeb sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).engageStopProcedure.func2+0x5b      /Users/fujianhao/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/manager/internal.go:575
#   0x1024ffb77 sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).engageStopProcedure+0x657   /Users/fujianhao/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/manager/internal.go:615
#   0x1024ff31f sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).Start.func2+0x3f        /Users/fujianhao/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/manager/internal.go:432
#   0x1024ff12b sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).Start+0x77b             /Users/fujianhao/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/manager/internal.go:515
#   0x1025b51bf main.main.func4+0x9f

Is this a bug? If so, I am interested in fixing it.

sbueringer commented 3 months ago

@alpha-baby I think this was fixed via https://github.com/kubernetes-sigs/controller-runtime/pull/2876

Can you please check?

k8s-triage-robot commented 1 week ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale