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
This commit is contained in:
parent
55a37ceef1
commit
78ccd1298e
|
@ -186,6 +186,8 @@ func TestLifecycle(t *testing.T) {
|
||||||
// ourselves.
|
// ourselves.
|
||||||
p, _ := os.FindProcess(s.Sandbox.Pid)
|
p, _ := os.FindProcess(s.Sandbox.Pid)
|
||||||
p.Wait()
|
p.Wait()
|
||||||
|
g, _ := os.FindProcess(s.Sandbox.GoferPid)
|
||||||
|
g.Wait()
|
||||||
|
|
||||||
// Load the container from disk and check the status.
|
// Load the container from disk and check the status.
|
||||||
s, err = container.Load(rootDir, id)
|
s, err = container.Load(rootDir, id)
|
||||||
|
|
|
@ -440,13 +440,27 @@ func (s *Sandbox) Signal(cid string, sig syscall.Signal) error {
|
||||||
return nil
|
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 {
|
func (s *Sandbox) IsRunning() bool {
|
||||||
// Send a signal 0 to the sandbox process.
|
if s.Pid != 0 {
|
||||||
if err := killProcess(s.Pid, 0); err != nil {
|
// Send a signal 0 to the sandbox process.
|
||||||
return false
|
if err := killProcess(s.Pid, 0); err == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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 false
|
||||||
}
|
}
|
||||||
|
|
||||||
// killProcess sends a signal to the host process (i.e. a sandbox or gofer
|
// killProcess sends a signal to the host process (i.e. a sandbox or gofer
|
||||||
|
|
Loading…
Reference in New Issue