From cd18a713e21a284f14f419617a2ac5424b028a80 Mon Sep 17 00:00:00 2001 From: Jiahao Huang Date: Thu, 19 Jan 2023 15:35:41 +0800 Subject: [PATCH] Fix goroutine lead in install action a case in RunWithContex() RunWithContex() { go i.performInstall // running for a longer time go i handleContex // return from ctx.Done() and send message to rchan, but performInstall is always running result := < -rChan //read message } the message in rchan will be received in RunWithContex(), and RunWithContex() returns soon. so, this case lead to goroutine performInstall leak Signed-off-by: Jiahao Huang --- pkg/action/install.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 425b66f69..44726e2e1 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -344,7 +344,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // not working. return rel, err } - rChan := make(chan resultMessage) + rChan := make(chan resultMessage, 2) doneChan := make(chan struct{}) defer close(doneChan) go i.performInstall(rChan, rel, toBeAdopted, resources) @@ -457,10 +457,10 @@ func (i *Install) failRelease(rel *release.Release, err error) (*release.Release // // Roughly, this will return an error if name is // -// - empty -// - too long -// - already in use, and not deleted -// - used by a deleted release, and i.Replace is false +// - empty +// - too long +// - already in use, and not deleted +// - used by a deleted release, and i.Replace is false func (i *Install) availableName() error { start := i.ReleaseName