From 612dfdd8134adefb9777726add5276e66dadb64d Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 23 Oct 2023 15:04:14 +0200 Subject: [PATCH] builder: return error if all nodes fail to boot Signed-off-by: CrazyMax --- builder/builder.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/builder.go b/builder/builder.go index 0ff7d93b60c..c387cd69c92 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -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 }