From 9d207b3e3c11cb9fd1eaf2ba73d3019c4a3c5939 Mon Sep 17 00:00:00 2001 From: David Zhu Date: Mon, 17 Sep 2018 16:57:05 -0700 Subject: [PATCH] GetMountRefs should not fail if the path supplied does not exist anymore. It has no mount references --- pkg/util/mount/mount_linux.go | 3 +++ pkg/volume/util/operationexecutor/operation_generator.go | 2 ++ test/e2e/storage/nfs_persistent_volume-disruptive.go | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/util/mount/mount_linux.go b/pkg/util/mount/mount_linux.go index 6b1c001044..180de0ffed 100644 --- a/pkg/util/mount/mount_linux.go +++ b/pkg/util/mount/mount_linux.go @@ -1005,6 +1005,9 @@ func (mounter *Mounter) SafeMakeDir(subdir string, base string, perm os.FileMode } func (mounter *Mounter) GetMountRefs(pathname string) ([]string, error) { + if _, err := os.Stat(pathname); os.IsNotExist(err) { + return []string{}, nil + } realpath, err := filepath.EvalSymlinks(pathname) if err != nil { return nil, err diff --git a/pkg/volume/util/operationexecutor/operation_generator.go b/pkg/volume/util/operationexecutor/operation_generator.go index 57c7adfa7c..154e3c8a2d 100644 --- a/pkg/volume/util/operationexecutor/operation_generator.go +++ b/pkg/volume/util/operationexecutor/operation_generator.go @@ -1433,6 +1433,8 @@ func isDeviceOpened(deviceToDetach AttachedVolume, mounter mount.Interface) (boo //TODO: refer to #36092 glog.V(3).Infof("The path isn't device path or doesn't exist. Skip checking device path: %s", deviceToDetach.DevicePath) deviceOpened = false + } else if devicePathErr != nil { + return false, deviceToDetach.GenerateErrorDetailed("PathIsDevice failed", devicePathErr) } else { deviceOpened, deviceOpenedErr = mounter.DeviceOpened(deviceToDetach.DevicePath) if deviceOpenedErr != nil { diff --git a/test/e2e/storage/nfs_persistent_volume-disruptive.go b/test/e2e/storage/nfs_persistent_volume-disruptive.go index 6482050a86..f081809dab 100644 --- a/test/e2e/storage/nfs_persistent_volume-disruptive.go +++ b/test/e2e/storage/nfs_persistent_volume-disruptive.go @@ -281,7 +281,7 @@ func tearDownTestCase(c clientset.Interface, f *framework.Framework, ns string, // Ignore deletion errors. Failing on them will interrupt test cleanup. framework.DeletePodWithWait(f, c, client) framework.DeletePersistentVolumeClaim(c, pvc.Name, ns) - if forceDeletePV { + if forceDeletePV && pv != nil { framework.DeletePersistentVolume(c, pv.Name) return }