From c06f97ad4b8a38e6396ff90f6084063f2303ad43 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Tue, 15 Jun 2021 21:55:19 -0700 Subject: vm/gvisor: stop instances properly (#2624) Let's stop instances with "runsc kill" instead of killing sandbox processes. This will guarantee that ongoing rpc calls will not fail with unexpected errors. Reported-by: syzbot+084fca334720887441e7@syzkaller.appspotmail.com --- vm/gvisor/gvisor.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'vm/gvisor') diff --git a/vm/gvisor/gvisor.go b/vm/gvisor/gvisor.go index 4365c22f9..31e3a10d5 100644 --- a/vm/gvisor/gvisor.go +++ b/vm/gvisor/gvisor.go @@ -316,8 +316,20 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin signal(err) return } - cmd.Process.Kill() - cmd.Wait() + log.Logf(1, "stopping %s", inst.name) + w := make(chan bool) + go func() { + select { + case <-w: + return + case <-time.After(time.Minute): + cmd.Process.Kill() + } + }() + osutil.Run(time.Minute, inst.runscCmd("kill", inst.name, "9")) + err := cmd.Wait() + close(w) + log.Logf(1, "%s exited with %s", inst.name, err) }() return inst.merger.Output, errc, nil } -- cgit mrf-deployment