Skip to content

Commit

Permalink
vm: check preemption string only for gce instances
Browse files Browse the repository at this point in the history
  • Loading branch information
dvyukov committed Jul 23, 2024
1 parent d505f90 commit 021e0b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions vm/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ import (

func init() {
vmimpl.Register("gce", vmimpl.Type{
Ctor: ctor,
Overcommit: true,
Ctor: ctor,
Overcommit: true,
Preemptible: true,
})
}

Expand Down
6 changes: 5 additions & 1 deletion vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (

type Pool struct {
impl vmimpl.Pool
typ vmimpl.Type
workdir string
template string
timeouts targets.Timeouts
Expand Down Expand Up @@ -128,6 +129,7 @@ func Create(cfg *mgrconfig.Config, debug bool) (*Pool, error) {
}
return &Pool{
impl: impl,
typ: typ,
workdir: env.Workdir,
template: cfg.WorkdirTemplate,
timeouts: cfg.Timeouts,
Expand Down Expand Up @@ -420,7 +422,9 @@ func (mon *monitor) extractError(defaultError string) *report.Report {
if defaultError != noOutputCrash || diagWait {
mon.waitForOutput()
}
if bytes.Contains(mon.output, []byte(executorPreemptedStr)) {
// Check the executorPreemptedStr only for preemptible instances since executor can print
// the string spuriously in some cases (gets SIGTERM from test program somehow).
if mon.inst.pool.typ.Preemptible && bytes.Contains(mon.output, []byte(executorPreemptedStr)) {
return nil
}
if defaultError == "" && mon.reporter.ContainsCrash(mon.output[mon.matchPos:]) {
Expand Down
4 changes: 4 additions & 0 deletions vm/vmimpl/vmimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ type Type struct {
// It's possible to create out-of-thin-air instances of this type.
// Out-of-thin-air instances are used by syz-ci for image testing, patch testing, bisection, etc.
Overcommit bool
// Instances of this type can be preempted and lost connection as the result.
// For preempted instances executor prints "SYZ-EXECUTOR: PREEMPTED" and then
// the host understands that the lost connection was expected and is not a bug.
Preemptible bool
}

type ctorFunc func(env *Env) (Pool, error)
Expand Down

0 comments on commit 021e0b5

Please sign in to comment.