progress: show logs for a failed vertex
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>docker-18.09
parent
2df68a5706
commit
d918b28961
|
@ -8,11 +8,18 @@ import (
|
|||
"github.com/moby/buildkit/util/system"
|
||||
)
|
||||
|
||||
type buildOpt struct {
|
||||
target string
|
||||
containerd string
|
||||
}
|
||||
|
||||
func main() {
|
||||
target := flag.String("target", "containerd", "target (standalone, containerd)")
|
||||
var opt buildOpt
|
||||
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
|
||||
flag.StringVar(&opt.containerd, "containerd", "master", "containerd version")
|
||||
flag.Parse()
|
||||
|
||||
bk := buildkit(*target == "containerd")
|
||||
bk := buildkit(opt)
|
||||
out := bk.Run(llb.Shlex("ls -l /bin")) // debug output
|
||||
|
||||
dt, err := out.Marshal()
|
||||
|
@ -45,7 +52,7 @@ func containerd(version string) *llb.State {
|
|||
Run(llb.Shlex("make bin/containerd")).Root()
|
||||
}
|
||||
|
||||
func buildkit(withContainerd bool) *llb.State {
|
||||
func buildkit(opt buildOpt) *llb.State {
|
||||
src := goBuildBase().With(goFromGit("github.com/moby/buildkit", "master"))
|
||||
|
||||
builddStandalone := src.
|
||||
|
@ -62,9 +69,9 @@ func buildkit(withContainerd bool) *llb.State {
|
|||
copyFrom(runc("v1.0.0-rc3"), "/usr/bin/runc", "/bin/"),
|
||||
)
|
||||
|
||||
if withContainerd {
|
||||
if opt.target == "containerd" {
|
||||
return r.With(
|
||||
copyFrom(containerd("master"), "/go/src/github.com/containerd/containerd/bin/containerd", "/bin/"),
|
||||
copyFrom(containerd(opt.containerd), "/go/src/github.com/containerd/containerd/bin/containerd", "/bin/"),
|
||||
copyFrom(builddContainerd, "/bin/buildd-containerd", "/bin/"))
|
||||
}
|
||||
return r.With(copyFrom(builddStandalone, "/bin/buildd-standalone", "/bin/"))
|
||||
|
|
|
@ -45,6 +45,7 @@ func DisplaySolveStatus(ctx context.Context, ch chan *client.SolveStatus) error
|
|||
|
||||
if done {
|
||||
disp.print(t.displayInfo(), true)
|
||||
t.printErrorLogs()
|
||||
return nil
|
||||
} else if displayLimiter.Allow() {
|
||||
disp.print(t.displayInfo(), false)
|
||||
|
@ -78,6 +79,7 @@ type vertex struct {
|
|||
*client.Vertex
|
||||
statuses []*status
|
||||
byID map[string]*status
|
||||
logs []*client.VertexLog
|
||||
}
|
||||
|
||||
type status struct {
|
||||
|
@ -120,6 +122,31 @@ func (t *trace) update(s *client.SolveStatus) {
|
|||
}
|
||||
v.byID[s.ID].VertexStatus = s
|
||||
}
|
||||
for _, l := range s.Logs {
|
||||
v, ok := t.byDigest[l.Vertex]
|
||||
if !ok {
|
||||
continue // shouldn't happen
|
||||
}
|
||||
v.logs = append(v.logs, l)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *trace) printErrorLogs() {
|
||||
for _, v := range t.vertexes {
|
||||
if v.Error != "" && !strings.HasSuffix(v.Error, context.Canceled.Error()) {
|
||||
fmt.Println("------")
|
||||
fmt.Printf(" > %s:\n", v.Name)
|
||||
for _, l := range v.logs {
|
||||
switch l.Stream {
|
||||
case 1:
|
||||
os.Stdout.Write(l.Data)
|
||||
case 2:
|
||||
os.Stderr.Write(l.Data)
|
||||
}
|
||||
}
|
||||
fmt.Println("------")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *trace) displayInfo() (d displayInfo) {
|
||||
|
|
Loading…
Reference in New Issue