cleanup buildkit errors everywhere
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
1d64422320
commit
0381c58d80
@ -203,8 +203,7 @@ func (c *Client) buildfn(ctx context.Context, ch chan *bk.SolveStatus, w io.Writ
|
||||
// Call buildkit solver
|
||||
resp, err := c.c.Build(ctx, opts, "", Compute, ch)
|
||||
if err != nil {
|
||||
err = errors.New(bkCleanError(err.Error()))
|
||||
return errors.Wrap(err, "buildkit solve")
|
||||
return errors.Wrap(bkCleanError(err), "buildkit solve")
|
||||
}
|
||||
for k, v := range resp.ExporterResponse {
|
||||
// FIXME consume exporter response
|
||||
@ -306,7 +305,7 @@ func (n Node) LogError(ctx context.Context, errmsg string) {
|
||||
Ctx(ctx).
|
||||
Error().
|
||||
Str("path", n.ComponentPath().String()).
|
||||
Msg(bkCleanError(errmsg))
|
||||
Msg(errmsg)
|
||||
}
|
||||
|
||||
func (c *Client) printfn(ctx context.Context, ch chan *bk.SolveStatus) error {
|
||||
@ -363,21 +362,6 @@ func (c *Client) printfn(ctx context.Context, ch chan *bk.SolveStatus) error {
|
||||
}
|
||||
}
|
||||
|
||||
// A helper to remove noise from buildkit error messages.
|
||||
// FIXME: Obviously a cleaner solution would be nice.
|
||||
func bkCleanError(msg string) string {
|
||||
noise := []string{
|
||||
"executor failed running ",
|
||||
"buildkit-runc did not terminate successfully",
|
||||
"rpc error: code = Unknown desc =",
|
||||
"failed to solve: ",
|
||||
}
|
||||
for _, s := range noise {
|
||||
msg = strings.Replace(msg, s, "", -1)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
func (c *Client) dockerprintfn(ctx context.Context, ch chan *bk.SolveStatus, out io.Writer) error {
|
||||
var cons console.Console
|
||||
// FIXME: use smarter writer from blr
|
||||
|
31
dagger/fs.go
31
dagger/fs.go
@ -4,9 +4,11 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/moby/buildkit/client/llb"
|
||||
bkgw "github.com/moby/buildkit/frontend/gateway/client"
|
||||
"github.com/pkg/errors"
|
||||
fstypes "github.com/tonistiigi/fsutil/types"
|
||||
)
|
||||
|
||||
@ -37,7 +39,7 @@ func (fs *FS) solve(ctx context.Context) error {
|
||||
}
|
||||
output, err := fs.s.Solve(ctx, fs.input)
|
||||
if err != nil {
|
||||
return err
|
||||
return bkCleanError(err)
|
||||
}
|
||||
fs.output = output
|
||||
return nil
|
||||
@ -54,7 +56,11 @@ func (fs FS) ReadFile(ctx context.Context, filename string) ([]byte, error) {
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
|
||||
return fs.output.ReadFile(ctx, bkgw.ReadRequest{Filename: filename})
|
||||
contents, err := fs.output.ReadFile(ctx, bkgw.ReadRequest{Filename: filename})
|
||||
if err != nil {
|
||||
return nil, bkCleanError(err)
|
||||
}
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func (fs FS) ReadDir(ctx context.Context, dir string) ([]Stat, error) {
|
||||
@ -72,7 +78,7 @@ func (fs FS) ReadDir(ctx context.Context, dir string) ([]Stat, error) {
|
||||
Path: dir,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, bkCleanError(err)
|
||||
}
|
||||
out := make([]Stat, len(st))
|
||||
for i := range st {
|
||||
@ -150,3 +156,22 @@ func (fs FS) Result(ctx context.Context) (*bkgw.Result, error) {
|
||||
res.SetRef(ref)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// A helper to remove noise from buildkit error messages.
|
||||
// FIXME: Obviously a cleaner solution would be nice.
|
||||
func bkCleanError(err error) error {
|
||||
noise := []string{
|
||||
"executor failed running ",
|
||||
"buildkit-runc did not terminate successfully",
|
||||
"rpc error: code = Unknown desc =",
|
||||
"failed to solve: ",
|
||||
}
|
||||
|
||||
msg := err.Error()
|
||||
|
||||
for _, s := range noise {
|
||||
msg = strings.Replace(msg, s, "", -1)
|
||||
}
|
||||
|
||||
return errors.New(msg)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func (s Solver) Solve(ctx context.Context, st llb.State) (bkgw.Reference, error)
|
||||
Evaluate: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, bkCleanError(err)
|
||||
}
|
||||
// always use single reference (ignore multiple outputs & metadata)
|
||||
return res.SingleRef()
|
||||
|
Reference in New Issue
Block a user