diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go index 3facb35cf..6cc0095f6 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -4,12 +4,14 @@ package mount import ( + "context" "crypto/md5" "encoding/hex" "errors" "fmt" "io/ioutil" "os" + "os/exec" "path" "path/filepath" "regexp" @@ -102,6 +104,7 @@ const ( mountPathRemoveDelay = 30 * time.Second testDeviceEnv = "Test_Device_Mounter" bindMountPrefix = "readonly" + statTimeout = 30 * time.Second ) var ( @@ -725,7 +728,11 @@ func (m *Mounter) removeMountPath(path string) error { // RemoveMountPath makes the path writeable and removes it after a fixed delay func (m *Mounter) RemoveMountPath(mountPath string, opts map[string]string) error { - if _, err := os.Stat(mountPath); err == nil { + ctx, cancel := context.WithTimeout(context.Background(), statTimeout) + defer cancel() + cmd := exec.CommandContext(ctx, "stat", mountPath) + _, err := cmd.CombinedOutput() + if err == nil { if options.IsBoolOptionSet(opts, options.OptionsWaitBeforeDelete) { hasher := md5.New() hasher.Write([]byte(mountPath))