From 1734abbb7685788f4ee54283e73839024b11ceea Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 14 Oct 2023 17:44:22 +0200 Subject: [PATCH] build: fix racy localstate group removal Signed-off-by: CrazyMax --- localstate/localstate.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/localstate/localstate.go b/localstate/localstate.go index f0ad0fbf..54ec9f39 100644 --- a/localstate/localstate.go +++ b/localstate/localstate.go @@ -127,22 +127,17 @@ func (ls *LocalState) RemoveBuilder(builderName string) error { if err != nil { return err } - - eg, _ := errgroup.WithContext(context.TODO()) for _, fi := range fis { - func(fi os.DirEntry) { - eg.Go(func() error { - return ls.RemoveBuilderNode(builderName, fi.Name()) - }) - }(fi) - } - if err := eg.Wait(); err != nil { - return err + if err := ls.RemoveBuilderNode(builderName, fi.Name()); err != nil { + return err + } } return os.RemoveAll(dir) } +// RemoveBuilderNode removes all refs for a builder node. +// This func is not safe for concurrent use from multiple goroutines. func (ls *LocalState) RemoveBuilderNode(builderName string, nodeName string) error { if builderName == "" { return errors.Errorf("builder name empty")