summaryrefslogtreecommitdiffhomepage
path: root/runsc/sandbox
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-06-04 12:13:33 -0700
committerShentubot <shentubot@google.com>2018-06-04 12:14:23 -0700
commit78ccd1298e1386d9c5e0eb10d328ecb16b28ea02 (patch)
tree872979aaaa07f8702eaacafeb897541878d5fc36 /runsc/sandbox
parent55a37ceef1e33cc72236db6e95f159963ddf40bd (diff)
Return 'running' if gofer is still alive
Containerd will start deleting container and rootfs after container is stopped. However, if gofer is still running, rootfs cleanup will fail because of device busy. This CL makes sure that gofer is not running when container state is stopped. Change from: lantaol@google.com PiperOrigin-RevId: 199172668 Change-Id: I9d874eec3ecf74fd9c8edd7f62d9f998edef66fe
Diffstat (limited to 'runsc/sandbox')
-rw-r--r--runsc/sandbox/sandbox.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go
index 91c44c996..bfaead1f2 100644
--- a/runsc/sandbox/sandbox.go
+++ b/runsc/sandbox/sandbox.go
@@ -440,13 +440,27 @@ func (s *Sandbox) Signal(cid string, sig syscall.Signal) error {
return nil
}
-// IsRunning returns true iff the sandbox process is running.
+// IsRunning returns true if the sandbox or gofer process is running.
func (s *Sandbox) IsRunning() bool {
- // Send a signal 0 to the sandbox process.
- if err := killProcess(s.Pid, 0); err != nil {
- return false
+ if s.Pid != 0 {
+ // Send a signal 0 to the sandbox process.
+ if err := killProcess(s.Pid, 0); err == nil {
+ return true
+ }
+ }
+ if s.GoferPid != 0 {
+ // Send a signal 0 to the gofer process.
+ if err := killProcess(s.GoferPid, 0); err == nil {
+ log.Warningf("Found orphan gofer process, pid: %d", s.GoferPid)
+ // Attempt to kill gofer if it's orphan.
+ killProcess(s.GoferPid, unix.SIGKILL)
+
+ // Don't wait for gofer to die. Return 'running' and hope gofer is dead
+ // next time around.
+ return true
+ }
}
- return true
+ return false
}
// killProcess sends a signal to the host process (i.e. a sandbox or gofer