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 <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Jun 7, 2023
1 parent 5d94b0f commit 3bca029
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func (b *Builder) Boot(ctx context.Context) (bool, error) {
}

baseCtx := ctx
errBoot := make(chan error)
eg, _ := errgroup.WithContext(ctx)
for _, idx := range toBoot {
func(idx int) {
Expand All @@ -171,18 +172,24 @@ 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
errBoot <- err
}
return nil
return err
})
}(idx)
}

err = eg.Wait()
close(errBoot)
err1 := printer.Wait()
if err == nil {
err = err1
}

// if all nodes failed to boot, we return an error
if len(errBoot) == len(toBoot) {
return false, err
}
return true, err
}

Expand Down

0 comments on commit 3bca029

Please sign in to comment.