mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Merge pull request #108363 from houjun41544/20220226-kubeletvolume
Fix error logging statement to make it easier to understand
This commit is contained in:
commit
68a0fccfb9
@ -122,7 +122,7 @@ func (kl *Kubelet) removeOrphanedPodVolumeDirs(uid types.UID) []error {
|
|||||||
// If there are still volume directories, attempt to rmdir them
|
// If there are still volume directories, attempt to rmdir them
|
||||||
volumePaths, err := kl.getPodVolumePathListFromDisk(uid)
|
volumePaths, err := kl.getPodVolumePathListFromDisk(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
orphanVolumeErrors = append(orphanVolumeErrors, fmt.Errorf("orphaned pod %q found, but error %v occurred during reading volume dir from disk", uid, err))
|
orphanVolumeErrors = append(orphanVolumeErrors, fmt.Errorf("orphaned pod %q found, but error occurred during reading volume dir from disk: %v", uid, err))
|
||||||
return orphanVolumeErrors
|
return orphanVolumeErrors
|
||||||
}
|
}
|
||||||
if len(volumePaths) > 0 {
|
if len(volumePaths) > 0 {
|
||||||
@ -138,7 +138,7 @@ func (kl *Kubelet) removeOrphanedPodVolumeDirs(uid types.UID) []error {
|
|||||||
// If there are any volume-subpaths, attempt to rmdir them
|
// If there are any volume-subpaths, attempt to rmdir them
|
||||||
subpathVolumePaths, err := kl.getPodVolumeSubpathListFromDisk(uid)
|
subpathVolumePaths, err := kl.getPodVolumeSubpathListFromDisk(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
orphanVolumeErrors = append(orphanVolumeErrors, fmt.Errorf("orphaned pod %q found, but error %v occurred during reading of volume-subpaths dir from disk", uid, err))
|
orphanVolumeErrors = append(orphanVolumeErrors, fmt.Errorf("orphaned pod %q found, but error occurred during reading of volume-subpaths dir from disk: %v", uid, err))
|
||||||
return orphanVolumeErrors
|
return orphanVolumeErrors
|
||||||
}
|
}
|
||||||
if len(subpathVolumePaths) > 0 {
|
if len(subpathVolumePaths) > 0 {
|
||||||
@ -155,7 +155,7 @@ func (kl *Kubelet) removeOrphanedPodVolumeDirs(uid types.UID) []error {
|
|||||||
// Fail if any regular files are encountered.
|
// Fail if any regular files are encountered.
|
||||||
podVolDir := kl.getPodVolumesDir(uid)
|
podVolDir := kl.getPodVolumesDir(uid)
|
||||||
if err := removeall.RemoveDirsOneFilesystem(kl.mounter, podVolDir); err != nil {
|
if err := removeall.RemoveDirsOneFilesystem(kl.mounter, podVolDir); err != nil {
|
||||||
orphanVolumeErrors = append(orphanVolumeErrors, fmt.Errorf("orphaned pod %q found, but error %v occurred when trying to remove the volumes dir", uid, err))
|
orphanVolumeErrors = append(orphanVolumeErrors, fmt.Errorf("orphaned pod %q found, but error occurred when trying to remove the volumes dir: %v", uid, err))
|
||||||
} else {
|
} else {
|
||||||
klog.InfoS("Cleaned up orphaned pod volumes dir", "podUID", uid, "path", podVolDir)
|
klog.InfoS("Cleaned up orphaned pod volumes dir", "podUID", uid, "path", podVolDir)
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ func (kl *Kubelet) cleanupOrphanedPodDirs(pods []*v1.Pod, runningPods []*kubecon
|
|||||||
podSubdirs, err := ioutil.ReadDir(podDir)
|
podSubdirs, err := ioutil.ReadDir(podDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "Could not read directory", "path", podDir)
|
klog.ErrorS(err, "Could not read directory", "path", podDir)
|
||||||
orphanRemovalErrors = append(orphanRemovalErrors, fmt.Errorf("orphaned pod %q found, but error %v occurred during reading the pod dir from disk", uid, err))
|
orphanRemovalErrors = append(orphanRemovalErrors, fmt.Errorf("orphaned pod %q found, but error occurred during reading the pod dir from disk: %v", uid, err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, podSubdir := range podSubdirs {
|
for _, podSubdir := range podSubdirs {
|
||||||
@ -228,7 +228,7 @@ func (kl *Kubelet) cleanupOrphanedPodDirs(pods []*v1.Pod, runningPods []*kubecon
|
|||||||
}
|
}
|
||||||
if err := removeall.RemoveAllOneFilesystem(kl.mounter, podSubdirPath); err != nil {
|
if err := removeall.RemoveAllOneFilesystem(kl.mounter, podSubdirPath); err != nil {
|
||||||
klog.ErrorS(err, "Failed to remove orphaned pod subdir", "podUID", uid, "path", podSubdirPath)
|
klog.ErrorS(err, "Failed to remove orphaned pod subdir", "podUID", uid, "path", podSubdirPath)
|
||||||
orphanRemovalErrors = append(orphanRemovalErrors, fmt.Errorf("orphaned pod %q found, but error %v occurred when trying to remove subdir %q", uid, err, podSubdirPath))
|
orphanRemovalErrors = append(orphanRemovalErrors, fmt.Errorf("orphaned pod %q found, but error occurred when trying to remove subdir %q: %v", uid, podSubdirPath, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ func (kl *Kubelet) cleanupOrphanedPodDirs(pods []*v1.Pod, runningPods []*kubecon
|
|||||||
klog.V(3).InfoS("Orphaned pod found, removing", "podUID", uid)
|
klog.V(3).InfoS("Orphaned pod found, removing", "podUID", uid)
|
||||||
if err := syscall.Rmdir(podDir); err != nil {
|
if err := syscall.Rmdir(podDir); err != nil {
|
||||||
klog.ErrorS(err, "Failed to remove orphaned pod dir", "podUID", uid)
|
klog.ErrorS(err, "Failed to remove orphaned pod dir", "podUID", uid)
|
||||||
orphanRemovalErrors = append(orphanRemovalErrors, fmt.Errorf("orphaned pod %q found, but error %v occurred when trying to remove the pod directory", uid, err))
|
orphanRemovalErrors = append(orphanRemovalErrors, fmt.Errorf("orphaned pod %q found, but error occurred when trying to remove the pod directory: %v", uid, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user