orphanVolumeErrors=append(orphanVolumeErrors,fmt.Errorf("orphaned pod %q found, but error %v occurred during reading of volume-subpaths dir from disk",uid,err))
returnorphanVolumeErrors
}
iflen(subpathVolumePaths)>0{
for_,subpathVolumePath:=rangesubpathVolumePaths{
iferr:=syscall.Rmdir(subpathVolumePath);err!=nil{
orphanVolumeErrors=append(orphanVolumeErrors,fmt.Errorf("orphaned pod %q found, but failed to rmdir() subpath at path %v: %v",uid,subpathVolumePath,err))
}else{
klog.Warningf("Cleaned up orphaned volume subpath from pod %q at %s",uid,subpathVolumePath)
}
}
}
// Remove any remaining subdirectories along with the volumes directory itself.
orphanVolumeErrors=append(orphanVolumeErrors,fmt.Errorf("orphaned pod %q found, but error %v occurred during reading of volume-subpaths dir from disk",uid,err))
klog.Errorf("Could not read directory %q; err: %v",podDir,err)
orphanRemovalErrors=append(orphanRemovalErrors,fmt.Errorf("orphaned pod %q found, but error %v occurred during reading the pod dir from disk",uid,err))
orphanVolumeErrors=append(orphanVolumeErrors,fmt.Errorf("orphaned pod %q found, but failed to rmdir() subpath at path %v: %v",uid,subpathVolumePath,err))
// Never attempt RemoveAllOneFilesystem on the volumes directory,
allVolumesCleanedUp=false
// as this could lead to data loss in some situations. The volumes
}else{
// directory should have been removed by removeOrphanedPodVolumeDirs.
klog.Warningf("Cleaned up orphaned volume subpath from pod %q at %s",uid,subpathVolumePath)
ifpodSubdirName=="volumes"{
}
err:=fmt.Errorf("volumes subdir was found after it was removed")
klog.Errorf("Orphaned pod %q found, but failed to remove volumes subdir %q; err: %v",uid,podSubdirPath,err)
klog.Errorf("Failed to remove orphaned pod %q subdir %q; err: %v",uid,podSubdirPath,err)
orphanRemovalErrors=append(orphanRemovalErrors,fmt.Errorf("orphaned pod %q found, but error %v occurred when trying to remove subdir %q",uid,err,podSubdirPath))
}
}
}
}
if!allVolumesCleanedUp{
// Rmdir the pod dir, which should be empty if everything above was successful
// Not all volumes were removed, so don't clean up the pod directory yet. It is likely
// that there are still mountpoints left which could stall RemoveAllOneFilesystem which
// would otherwise be called below.
// Errors for all removal operations have already been recorded, so don't add another
// one here.
continue
}
klog.V(3).Infof("Orphaned pod %q found, removing",uid)
klog.V(3).Infof("Orphaned pod %q found, removing",uid)
orphanRemovalErrors=append(orphanRemovalErrors,fmt.Errorf("orphaned pod %q found, but error %v occurred when trying to remove the pod directory",uid,err))