Check for defunct process before waiting for it
This commit is contained in:
parent
82ab4b0983
commit
a468d955bc
1 changed files with 12 additions and 6 deletions
|
@ -17,6 +17,18 @@ func waitForProcess(p *os.Process, backoff int) error {
|
||||||
if backoff == 20 {
|
if backoff == 20 {
|
||||||
return fmt.Errorf("Timeout waiting for PID %v to end", p.Pid)
|
return fmt.Errorf("Timeout waiting for PID %v to end", p.Pid)
|
||||||
}
|
}
|
||||||
|
cmdLine, err := getCmdLine(p.Pid)
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("Error checking cmdline of PID %v, assuming it is dead: %s", p.Pid, err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if cmdLine == "" {
|
||||||
|
// ignore defunct processes
|
||||||
|
// TODO: debug why this happens in the first place
|
||||||
|
// seems to only happen on k8s, not on local docker
|
||||||
|
glog.Warning("Fuse process seems dead, returning")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if err := p.Signal(syscall.Signal(0)); err != nil {
|
if err := p.Signal(syscall.Signal(0)); err != nil {
|
||||||
glog.Warningf("Fuse process does not seem active or we are unprivileged: %s", err)
|
glog.Warningf("Fuse process does not seem active or we are unprivileged: %s", err)
|
||||||
return nil
|
return nil
|
||||||
|
@ -38,12 +50,6 @@ func findFuseMountProcess(path string, name string) (*os.Process, error) {
|
||||||
glog.Errorf("Unable to get cmdline of PID %v: %s", p.Pid(), err)
|
glog.Errorf("Unable to get cmdline of PID %v: %s", p.Pid(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cmdLine == "" {
|
|
||||||
// ignore defunct processes
|
|
||||||
// TODO: debug why this happens in the first place
|
|
||||||
// seems to only happen on k8s, not on local docker
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strings.Contains(cmdLine, path) {
|
if strings.Contains(cmdLine, path) {
|
||||||
glog.Infof("Found matching pid %v on path %s", p.Pid(), path)
|
glog.Infof("Found matching pid %v on path %s", p.Pid(), path)
|
||||||
return os.FindProcess(p.Pid())
|
return os.FindProcess(p.Pid())
|
||||||
|
|
Loading…
Reference in a new issue