mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Remove potential Goroutine leak in kubeadm wait.go
There are two writes yet only one read on a non-buffered channel that is created locally and not passed anywhere else. Therefore, it could leak one of its two spawned Goroutines if either: * The provided `f` takes longer than an erroneous result from `waiter.WaitForHealthyKubelet`, or; * The provided `f` completes before an erroneous result from `waiter.WaitForHealthyKubelet`. The fix is to add a one-element buffer so that the channel write happens for the second Goroutine in these cases, allowing it to finish and freeing references to the now-buffered channel, letting it to be GC'd.
This commit is contained in:
committed by
LouisJackman
parent
bef8d426f2
commit
62e314a556
@@ -157,7 +157,7 @@ func (w *KubeWaiter) WaitForHealthyKubelet(initalTimeout time.Duration, healthzE
|
||||
// WaitForKubeletAndFunc waits primarily for the function f to execute, even though it might take some time. If that takes a long time, and the kubelet
|
||||
// /healthz continuously are unhealthy, kubeadm will error out after a period of exponential backoff
|
||||
func (w *KubeWaiter) WaitForKubeletAndFunc(f func() error) error {
|
||||
errorChan := make(chan error)
|
||||
errorChan := make(chan error, 1)
|
||||
|
||||
go func(errC chan error, waiter Waiter) {
|
||||
if err := waiter.WaitForHealthyKubelet(40*time.Second, fmt.Sprintf("http://localhost:%d/healthz", kubeadmconstants.KubeletHealthzPort)); err != nil {
|
||||
|
Reference in New Issue
Block a user