Fix goroutine leak in action install

During the install process there was a place where an install
process could be stuck trying to write to a channel. This would
happen when a context had completed prior to performInstall
finishing. In a short running Helm Client this was not a problem.
But, for long running applications that use Helm as an SDK there
are problems where a memory leak ends up happening due to
goroutines never being able to complete.

This fix provides a means for performInstall to write to its
channel using the method already used to fix the upgrade
issue of the same kind.

Fixes #11805

Signed-off-by: Matt Farina <matt.farina@suse.com>
pull/11978/head
Matt Farina 2 years ago
parent 10587613cf
commit 7c9d636f40
No known key found for this signature in database
GPG Key ID: 92C44A3D421FF7F9

@ -369,14 +369,18 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma
return rel, err return rel, err
} }
rChan := make(chan resultMessage) rChan := make(chan resultMessage)
ctxChan := make(chan resultMessage)
doneChan := make(chan struct{}) doneChan := make(chan struct{})
defer close(doneChan) defer close(doneChan)
go i.performInstall(rChan, rel, toBeAdopted, resources) go i.performInstall(rChan, rel, toBeAdopted, resources)
go i.handleContext(ctx, rChan, doneChan, rel) go i.handleContext(ctx, ctxChan, doneChan, rel)
result := <-rChan select {
//start preformInstall go routine case result := <-rChan:
return result.r, result.e
case result := <-ctxChan:
return result.r, result.e return result.r, result.e
} }
}
func (i *Install) performInstall(c chan<- resultMessage, rel *release.Release, toBeAdopted kube.ResourceList, resources kube.ResourceList) { func (i *Install) performInstall(c chan<- resultMessage, rel *release.Release, toBeAdopted kube.ResourceList, resources kube.ResourceList) {

Loading…
Cancel
Save