mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
monitor: print error information before launching monitor
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
parent
8da8ee2aea
commit
0dd89f6029
@ -391,6 +391,11 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if options.invokeConfig != nil && options.invokeConfig.needsDebug(retErr) {
|
if options.invokeConfig != nil && options.invokeConfig.needsDebug(retErr) {
|
||||||
|
// Print errors before launching monitor
|
||||||
|
if err := printError(retErr, printer); err != nil {
|
||||||
|
logrus.Warnf("failed to print error information: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
pr2, pw2 := io.Pipe()
|
pr2, pw2 := io.Pipe()
|
||||||
f.SetWriter(pw2, func() io.WriteCloser {
|
f.SetWriter(pw2, func() io.WriteCloser {
|
||||||
pw2.Close() // propagate EOF
|
pw2.Close() // propagate EOF
|
||||||
@ -412,6 +417,18 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
|
|||||||
return resp, retErr
|
return resp, retErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printError(err error, printer *progress.Printer) error {
|
||||||
|
if err := printer.Pause(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer printer.Unpause()
|
||||||
|
for _, s := range errdefs.Sources(err) {
|
||||||
|
s.Print(os.Stderr)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func newDebuggableBuild(dockerCli command.Cli, rootOpts *rootOptions) debug.DebuggableCmd {
|
func newDebuggableBuild(dockerCli command.Cli, rootOpts *rootOptions) debug.DebuggableCmd {
|
||||||
return &debuggableBuild{dockerCli: dockerCli, rootOpts: rootOpts}
|
return &debuggableBuild{dockerCli: dockerCli, rootOpts: rootOpts}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user