Skip to content

Instantly share code, notes, and snippets.

@chrischdi
Last active May 16, 2019 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrischdi/de315391b229cb28f01ad35ec04511d2 to your computer and use it in GitHub Desktop.
Save chrischdi/de315391b229cb28f01ad35ec04511d2 to your computer and use it in GitHub Desktop.
diff --git a/pkg/util/mount/nsenter_mount.go b/pkg/util/mount/nsenter_mount.go
index 5f013bb7ce..0b0eca412d 100644
--- a/pkg/util/mount/nsenter_mount.go
+++ b/pkg/util/mount/nsenter_mount.go
@@ -167,6 +167,12 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
return true, err
}
+ // Check the directory is a corrupted mountpoint
+ if _, err = os.Stat(file); IsCorruptedMnt(err) {
+ klog.V(5).Infof("findmnt: directory %s is a corrupted mount", file)
+ return true, err
+ }
+
// Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts
resolvedFile, err := n.EvalHostSymlinks(file)
if err != nil {
diff --git a/pkg/volume/csi/csi_mounter.go b/pkg/volume/csi/csi_mounter.go
index 0f2d5424f6..2564124e0d 100644
--- a/pkg/volume/csi/csi_mounter.go
+++ b/pkg/volume/csi/csi_mounter.go
@@ -297,12 +297,12 @@ func (c *csiMountMgr) TearDownAt(dir string) error {
// TODO (vladimirvivien) this check may not work for an emptyDir or local storage
// see https://github.com/kubernetes/kubernetes/pull/56836#discussion_r155834524
mounted, err := isDirMounted(c.plugin, dir)
- if err != nil {
+ if err != nil && !util.IsCorruptedMnt(err) {
klog.Error(log("unmounter.Teardown failed while checking mount status for dir [%s]: %v", dir, err))
return err
}
- if !mounted {
+ if !mounted && !util.IsCorruptedMnt(err) {
klog.V(4).Info(log("unmounter.Teardown skipping unmount, dir not mounted [%s]", dir))
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment