fmt.Fprintf(os.Stderr,"Using deprecated annotation `kubectl.kubernetes.io/default-logs-container` in pod/%v. Please use `kubectl.kubernetes.io/default-container` instead\n",t.Name)
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.InfoS("Cleaned up orphaned volume subpath from pod","podUID",uid,"path",subpathVolumePath)
}
}
}
// Remove any remaining subdirectories along with the volumes directory itself.
// Call RemoveAllOneFilesystem for remaining subdirs under the pod directory
podDir:=kl.getPodDir(uid)
podSubdirs,err:=ioutil.ReadDir(podDir)
iferr!=nil{
orphanVolumeErrors=append(orphanVolumeErrors,fmt.Errorf("orphaned pod %q found, but error %v occurred during reading of volume-subpaths dir from disk",uid,err))
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))
continue
}
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))
allVolumesCleanedUp=false
}else{
klog.InfoS("Cleaned up orphaned volume subpath from pod","podUID",uid,"path",subpathVolumePath)
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))
}
}
if!allVolumesCleanedUp{
// 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
}
// Rmdir the pod dir, which should be empty if everything above was successful
klog.V(3).InfoS("Orphaned pod found, removing","podUID",uid)
orphanRemovalErrors=append(orphanRemovalErrors,fmt.Errorf("orphaned pod %q found, but error %v occurred when trying to remove the pod directory",uid,err))