integration: print containerd logs on failure

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
docker-18.09
Akihiro Suda 2018-08-23 17:43:32 +09:00
parent decb27618b
commit b90615d34d
1 changed files with 15 additions and 4 deletions

View File

@ -102,14 +102,15 @@ state = %q
logs := map[string]*bytes.Buffer{}
if stop, err := startCmd(cmd, logs); err != nil {
ctdStop, err := startCmd(cmd, logs)
if err != nil {
return nil, nil, err
} else {
deferF.append(stop)
}
if err := waitUnix(address, 5*time.Second); err != nil {
return nil, nil, err
ctdStop()
return nil, nil, errors.Wrapf(err, "containerd did not start up: %s", formatLogs(logs))
}
deferF.append(ctdStop)
buildkitdSock, stop, err := runBuildkitd([]string{"buildkitd",
"--oci-worker=false",
@ -123,6 +124,16 @@ state = %q
return &cdsandbox{address: address, sandbox: sandbox{address: buildkitdSock, logs: logs, cleanup: deferF, rootless: false}}, cl, nil
}
func formatLogs(m map[string]*bytes.Buffer) string {
var ss []string
for k, b := range m {
if b != nil {
ss = append(ss, fmt.Sprintf("%q:%q", k, b.String()))
}
}
return strings.Join(ss, ",")
}
type cdsandbox struct {
sandbox
address string