Move error reporting to volume plugins

Move reporting of GetReliableMountRefs error to the volume plugins that
have more context about severity of the error.
This commit is contained in:
Jan Safranek 2021-05-26 20:45:56 +02:00
parent a95842095e
commit f9a04f3bc4
3 changed files with 12 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
"k8s.io/utils/io"
utilstrings "k8s.io/utils/strings"
v1 "k8s.io/api/core/v1"
@ -246,6 +247,11 @@ func (plugin *fcPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volu
// The volume can then be mounted on several nodes, resulting in volume
// corruption.
paths, err := util.GetReliableMountRefs(mounter, mountPath)
if io.IsInconsistentReadError(err) {
klog.Errorf("Failed to read mount refs from /proc/mounts for %s: %s", mountPath, err)
klog.Errorf("Kubelet cannot unmount volume at %s, please unmount it manually", mountPath)
return nil, err
}
if err != nil {
return nil, err
}

View File

@ -27,6 +27,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
"k8s.io/utils/io"
"k8s.io/utils/keymutex"
utilstrings "k8s.io/utils/strings"
@ -224,6 +225,11 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
// The volume can then be mounted on several nodes, resulting in volume
// corruption.
paths, err := util.GetReliableMountRefs(mounter, mountPath)
if io.IsInconsistentReadError(err) {
klog.Errorf("Failed to read mount refs from /proc/mounts for %s: %s", mountPath, err)
klog.Errorf("Kubelet cannot unmount volume at %s, please unmount it and all mounts of the same device manually.", mountPath)
return nil, err
}
if err != nil {
return nil, err
}

View File

@ -754,8 +754,6 @@ func GetReliableMountRefs(mounter mount.Interface, mountPath string) ([]string,
return true, nil
})
if err == wait.ErrWaitTimeout {
klog.Errorf("Failed to read mount refs from /proc/mounts for %s: %s", mountPath, err)
klog.Errorf("Kubelet cannot unmount volume at %s, please unmount it manually", mountPath)
return nil, lastErr
}
return paths, err