kubernetes: Failed to delete pod volume because of directory not empty

What happened:

When then init process of pod is blocking in requesting remote url,I delete the pod.But the init process is still blocking and the umonter is umounting pod volume.At the same time,the process wakes up and writes something to volume,leading to something left in pod volume path(Mine is /var/lib/kubelet/pods/ea23394f-db52-11e8-ad88-6c92bf6f20b2/volumes/hulk~lvm/hulklvm).Then the umounter is trying to rmdir pod volume path.But it failed and print:

nestedpendingoperations.go:262] Operation for "\"hulk/lvm/hulklvm\" (\"ea23394f-db52-11e8-ad88-6c92bf6f20b2\")" failed. No retries permitted until 2018-10-29 16:16:38.785298614 +0800 CST (durationBeforeRetry 500ms). Error: UnmountVolume.TearDown failed for volume "hulk/lvm/hulklvm" (volume.spec.Name: "hulklvm") pod "ea23394f-db52-11e8-ad88-6c92bf6f20b2" (UID: "ea23394f-db52-11e8-ad88-6c92bf6f20b2") with: remove /var/lib/kubelet/pods/ea23394f-db52-11e8-ad88-6c92bf6f20b2/volumes/hulk~lvm/hulklvm: directory not empty

What you expected to happen:

image

It should remove the volume path even if directory not empty.Means in umounter/TearDownAt, we should use os.RemoveAll at end instead of os.Remove

How to reproduce it (as minimally and precisely as possible):

while creating a pod and pod is stucked ,delete it

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):1.6.6
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):centos 7
  • Kernel (e.g. uname -a):3.10.0-693.mt20180403.47.el7.x86_64
  • Install tools:
  • Others:

/kind bug

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Hello, I can’t see any merged pull request about this old bug. Still having this trouble in 1.28 : kubernetes.io/csi: Unmounter.TearDownAt failed to clean mount dir [/var/lib/k0s/kubelet/pods/02ed9377-7060-4ed4-8caf-995b5b47cf2a/volumes/kubernetes.io~csi/media-pv/mount]: kubernetes.io/csi: failed to remove dir [/var/lib/k0s/kubelet/pods/02ed9377-7060-4ed4-8caf-995b5b47cf2a/volumes/kubernetes.io~csi/media-pv/mount]: remove /var/lib/k0s/kubelet/pods/02ed9377-7060-4ed4-8caf-995b5b47cf2a/volumes/kubernetes.io~csi/media-pv/mount: directory not empty"