mirror of https://github.com/docker/buildx.git
build: fix racy localstate group removal
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
ac93a7fbfb
commit
1734abbb76
|
@ -127,22 +127,17 @@ func (ls *LocalState) RemoveBuilder(builderName string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
eg, _ := errgroup.WithContext(context.TODO())
|
|
||||||
for _, fi := range fis {
|
for _, fi := range fis {
|
||||||
func(fi os.DirEntry) {
|
if err := ls.RemoveBuilderNode(builderName, fi.Name()); err != nil {
|
||||||
eg.Go(func() error {
|
return err
|
||||||
return ls.RemoveBuilderNode(builderName, fi.Name())
|
}
|
||||||
})
|
|
||||||
}(fi)
|
|
||||||
}
|
|
||||||
if err := eg.Wait(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return os.RemoveAll(dir)
|
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 {
|
func (ls *LocalState) RemoveBuilderNode(builderName string, nodeName string) error {
|
||||||
if builderName == "" {
|
if builderName == "" {
|
||||||
return errors.Errorf("builder name empty")
|
return errors.Errorf("builder name empty")
|
||||||
|
|
Loading…
Reference in New Issue