Parallelize read-only volume check pass for volume.check.disk. (#7602)

This commit is contained in:
Lisandro Pin
2025-12-02 18:29:27 +01:00
committed by GitHub
parent 733ca8e6df
commit ee775825bc
2 changed files with 39 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ package shell
import (
"errors"
"fmt"
"sync"
)
@@ -64,6 +65,13 @@ func (ewg *ErrorWaitGroup) Add(f ErrorWaitGroupTask) {
}()
}
// AddErrorf adds an error to an ErrorWaitGroupTask result, without queueing any goroutines.
func (ewg *ErrorWaitGroup) AddErrorf(format string, a ...interface{}) {
ewg.errorsMu.Lock()
ewg.errors = append(ewg.errors, fmt.Errorf(format, a...))
ewg.errorsMu.Unlock()
}
// Wait sleeps until all ErrorWaitGroupTasks are completed, then returns errors for them.
func (ewg *ErrorWaitGroup) Wait() error {
ewg.wg.Wait()