mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
build: when building multiple targets include name in error
Some errors can appear without a stacktrace or progress record, eg. wrong Dockerfile name passed. In that case when building many targets with bake it might be hard to figure out which target failed as in the progressbar there will only be steps that were cancelled. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
07a85a544b
commit
246a36d463
@ -309,7 +309,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||||||
childTargets := calculateChildTargets(reqForNodes, opt)
|
childTargets := calculateChildTargets(reqForNodes, opt)
|
||||||
|
|
||||||
for k, opt := range opt {
|
for k, opt := range opt {
|
||||||
err := func(k string) error {
|
err := func(k string) (err error) {
|
||||||
opt := opt
|
opt := opt
|
||||||
dps := drivers[k]
|
dps := drivers[k]
|
||||||
multiDriver := len(drivers[k]) > 1
|
multiDriver := len(drivers[k]) > 1
|
||||||
@ -321,6 +321,12 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||||||
}
|
}
|
||||||
baseCtx := ctx
|
baseCtx := ctx
|
||||||
|
|
||||||
|
if multiTarget {
|
||||||
|
defer func() {
|
||||||
|
err = errors.Wrapf(err, "target %s", k)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
res := make([]*client.SolveResponse, len(dps))
|
res := make([]*client.SolveResponse, len(dps))
|
||||||
eg2, ctx := errgroup.WithContext(ctx)
|
eg2, ctx := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
@ -563,6 +569,13 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||||||
tracing.FinishWithError(span, err)
|
tracing.FinishWithError(span, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if multiTarget {
|
||||||
|
defer func() {
|
||||||
|
err = errors.Wrapf(err, "target %s", k)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
pw := progress.WithPrefix(w, "default", false)
|
pw := progress.WithPrefix(w, "default", false)
|
||||||
if err := eg2.Wait(); err != nil {
|
if err := eg2.Wait(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user