Skip to content

Commit

Permalink
builder: return error if all nodes fail to boot
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Oct 24, 2023
1 parent 7838ade commit 612dfdd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,25 +165,31 @@ 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 {
pw := progress.WithPrefix(printer, b.NodeGroup.Nodes[idx].Name, len(toBoot) > 1)
_, err := driver.Boot(ctx, baseCtx, b.nodes[idx].Driver, pw)
if err != nil {
b.nodes[idx].Err = err
errCh <- err
}
return nil
})
}(idx)
}

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
}

Expand Down

0 comments on commit 612dfdd

Please sign in to comment.