diff options
| author | Viktor Kuzmin <kvaster@gmail.com> | 2022-09-03 11:40:32 +0300 |
|---|---|---|
| committer | Viktor Kuzmin <kvaster@gmail.com> | 2022-09-03 11:40:32 +0300 |
| commit | bc49fc11ffe8c687c5d4ea46f25ead9191155ec0 (patch) | |
| tree | 901e66a4e89fb8d23648ca51c438f74c13bfcc35 /pkg/driver/mount_util.go | |
| parent | 3e3d202acdc9cb523ae3f7e71b3e1b595f4d5450 (diff) | |
| download | seaweedfs-csi-driver-bc49fc11ffe8c687c5d4ea46f25ead9191155ec0.tar.xz seaweedfs-csi-driver-bc49fc11ffe8c687c5d4ea46f25ead9191155ec0.zip | |
Remove linux specific magic from fuse process start/stop.
Use pid from cmd.Process instead of /proc lookup
Use mount specific mutex
Log fuse mount process stderr and stdout for problems investigation
Diffstat (limited to 'pkg/driver/mount_util.go')
| -rw-r--r-- | pkg/driver/mount_util.go | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/pkg/driver/mount_util.go b/pkg/driver/mount_util.go index af72840..561a499 100644 --- a/pkg/driver/mount_util.go +++ b/pkg/driver/mount_util.go @@ -2,43 +2,11 @@ package driver import ( "errors" - "fmt" - "io/ioutil" - "os" - "strings" - "syscall" "time" - "github.com/mitchellh/go-ps" - "github.com/seaweedfs/seaweedfs/weed/glog" "k8s.io/utils/mount" ) -func waitForProcess(p *os.Process, backoff int) error { - if backoff == 20 { - 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 { - glog.Warningf("Fuse process does not seem active or we are unprivileged: %s", err) - return nil - } - glog.Infof("Fuse process with PID %v still active, waiting...", p.Pid) - time.Sleep(time.Duration(backoff*100) * time.Millisecond) - return waitForProcess(p, backoff+1) -} - func waitForMount(path string, timeout time.Duration) error { var elapsed time.Duration var interval = 10 * time.Millisecond @@ -57,31 +25,3 @@ func waitForMount(path string, timeout time.Duration) error { } } } - -func findFuseMountProcess(path string) (*os.Process, error) { - processes, err := ps.Processes() - if err != nil { - return nil, err - } - for _, p := range processes { - cmdLine, err := getCmdLine(p.Pid()) - if err != nil { - glog.Errorf("Unable to get cmdline of PID %v: %s", p.Pid(), err) - continue - } - if strings.Contains(cmdLine, path) { - glog.Infof("Found matching pid %v on path %s", p.Pid(), path) - return os.FindProcess(p.Pid()) - } - } - return nil, nil -} - -func getCmdLine(pid int) (string, error) { - cmdLineFile := fmt.Sprintf("/proc/%v/cmdline", pid) - cmdLine, err := ioutil.ReadFile(cmdLineFile) - if err != nil { - return "", err - } - return string(cmdLine), nil -} |
