Skip to content

Commit

Permalink
Merge branch 'libopenstorage:master' into defrag_schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
twang-ps authored Feb 15, 2024
2 parents 89559b0 + ac3b370 commit 0f83f33
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
package mount

import (
"context"
"crypto/md5"
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -102,6 +104,7 @@ const (
mountPathRemoveDelay = 30 * time.Second
testDeviceEnv = "Test_Device_Mounter"
bindMountPrefix = "readonly"
statTimeout = 30 * time.Second
)

var (
Expand Down Expand Up @@ -708,7 +711,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))
Expand Down

0 comments on commit 0f83f33

Please sign in to comment.