From 3bca029df9e16487eeb0cae1caf6d4281810fa8b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 7 Jun 2023 15:10:57 +0200 Subject: [PATCH] builder: return error if all nodes fail to boot Signed-off-by: CrazyMax --- builder/builder.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/builder/builder.go b/builder/builder.go index 8353c84c..10955741 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -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) { @@ -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 }