aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/instance
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-12-16 16:48:05 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-12-16 16:48:05 +0100
commit1749e412ca50caa145ba53de69c0daf95f1b6d6f (patch)
tree850142fcd2119a0a7196973a77560b92eeecd3b0 /pkg/instance
parentce6744512e81ac2e291fea247d55fb0bf8e703e2 (diff)
pkg/instance: make kernel reboot detection portable
The current code is linux specific, generalize it to other OSes.
Diffstat (limited to 'pkg/instance')
-rw-r--r--pkg/instance/instance.go20
1 files changed, 9 insertions, 11 deletions
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
}