From 1749e412ca50caa145ba53de69c0daf95f1b6d6f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 16 Dec 2018 16:48:05 +0100 Subject: pkg/instance: make kernel reboot detection portable The current code is linux specific, generalize it to other OSes. --- pkg/instance/instance.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'pkg/instance') diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index cc04c5b35..1d35efa75 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -6,7 +6,6 @@ package instance import ( - "bytes" "encoding/json" "fmt" "net" @@ -201,24 +200,23 @@ func (inst *inst) test() error { } if bootErr, ok := err.(vm.BootErrorer); ok { testErr.Title, testErr.Output = bootErr.BootError() - // This linux-ism avoids detecting any crash during boot as "unexpected kernel reboot". - output := testErr.Output - if pos := bytes.Index(output, []byte("Booting the kernel.")); pos != -1 { - output = output[pos+1:] + rep := inst.reporter.Parse(testErr.Output) + if rep != nil && rep.Title == report.UnexpectedKernelReboot { + // Avoid detecting any boot crash as "unexpected kernel reboot". + rep = inst.reporter.Parse(testErr.Output[rep.EndPos:]) } - testErr.Report = inst.reporter.Parse(output) - if testErr.Report != nil { - testErr.Title = testErr.Report.Title - } else { - testErr.Report = &report.Report{ + if rep == nil { + rep = &report.Report{ Title: testErr.Title, Output: testErr.Output, } } - if err := inst.reporter.Symbolize(testErr.Report); err != nil { + if err := inst.reporter.Symbolize(rep); err != nil { // TODO(dvyukov): send such errors to dashboard. log.Logf(0, "failed to symbolize report: %v", err) } + testErr.Report = rep + testErr.Title = rep.Title } return testErr } -- cgit mrf-deployment