mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
builder: return error if all nodes fail to boot
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
7838ade9f3
commit
612dfdd813
@ -165,6 +165,7 @@ func (b *Builder) Boot(ctx context.Context) (bool, error) {
|
||||
|
||||
baseCtx := ctx
|
||||
eg, _ := errgroup.WithContext(ctx)
|
||||
errCh := make(chan error, len(toBoot))
|
||||
for _, idx := range toBoot {
|
||||
func(idx int) {
|
||||
eg.Go(func() error {
|
||||
@ -172,6 +173,7 @@ func (b *Builder) Boot(ctx context.Context) (bool, error) {
|
||||
_, err := driver.Boot(ctx, baseCtx, b.nodes[idx].Driver, pw)
|
||||
if err != nil {
|
||||
b.nodes[idx].Err = err
|
||||
errCh <- err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@ -179,11 +181,15 @@ func (b *Builder) Boot(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
err = eg.Wait()
|
||||
close(errCh)
|
||||
err1 := printer.Wait()
|
||||
if err == nil {
|
||||
err = err1
|
||||
}
|
||||
|
||||
if err == nil && len(errCh) == len(toBoot) {
|
||||
return false, <-errCh
|
||||
}
|
||||
return true, err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user