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)
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.
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))
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.InfoS("Cleaned up orphaned volume subpath from pod","podUID",uid,"path",subpathVolumePath)
ifpodSubdirName=="volumes"{
}
err:=fmt.Errorf("volumes subdir was found after it was removed")
klog.ErrorS(err,"Orphaned pod found, but failed to remove volumes 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))
}
}
}
}
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).InfoS("Orphaned pod found, removing","podUID",uid)
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))