Skip to content

Commit

Permalink
PWX-33580 Run stat command with timeout during NFS Unmount (#2403) (#…
Browse files Browse the repository at this point in the history
…2457)

* Made changes to run stat command with a timeout of 60 secondss



* Change implementation using context as pexec is part of porx



---------

Signed-off-by: Vignesh Laxman <[email protected]>
  • Loading branch information
vlaxman-px authored Jul 11, 2024
1 parent f318e40 commit 0ba1aa1
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 @@ -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))
Expand Down

0 comments on commit 0ba1aa1

Please sign in to comment.