mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
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:
parent
a95842095e
commit
f9a04f3bc4
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user