builder: return error if all nodes fail to boot
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -163,6 +163,7 @@ func (b *Builder) Boot(ctx context.Context) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseCtx := ctx
|
baseCtx := ctx
|
||||||
|
errBoot := make(chan error)
|
||||||
eg, _ := errgroup.WithContext(ctx)
|
eg, _ := errgroup.WithContext(ctx)
|
||||||
for _, idx := range toBoot {
|
for _, idx := range toBoot {
|
||||||
func(idx int) {
|
func(idx int) {
|
||||||
@@ -171,18 +172,24 @@ func (b *Builder) Boot(ctx context.Context) (bool, error) {
|
|||||||
_, err := driver.Boot(ctx, baseCtx, b.nodes[idx].Driver, pw)
|
_, err := driver.Boot(ctx, baseCtx, b.nodes[idx].Driver, pw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.nodes[idx].Err = err
|
b.nodes[idx].Err = err
|
||||||
|
errBoot <- err
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
})
|
})
|
||||||
}(idx)
|
}(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = eg.Wait()
|
err = eg.Wait()
|
||||||
|
close(errBoot)
|
||||||
err1 := printer.Wait()
|
err1 := printer.Wait()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = err1
|
err = err1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if all nodes failed to boot, we return an error
|
||||||
|
if len(errBoot) == len(toBoot) {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user