kubernetes: Pod is stuck in terminating with "MountVolume.SetUp failed for volume ... not registered" error

What happened?

Pod is stuck in terminating state when rapidly create and delete the pod, and the kubelet reported the volume setup error:

Oct 21 12:09:20 slave2 kubelet[4089]: E1021 12:09:20.197090    4089 nestedpendingoperations.go:348] Operation for "{volumeName:kubernetes.io/secret/dc79f107-6576-4d98-a120-23336154393e-tls-cert-vol podName:dc79f107-6576-4d98-a120-23336154393e nodeName:}" failed. No retries permitted until 2022-10-21 12:11:22.19703932 +0800 CST m=+323223.503182418 (durationBeforeRetry 2m2s). Error: MountVolume.SetUp failed for volume "tls-cert-vol" (UniqueName: "kubernetes.io/secret/dc79f107-6576-4d98-a120-23336154393e-tls-cert-vol") pod "vela-core-8494697c8c-xgrwt" (UID: "dc79f107-6576-4d98-a120-23336154393e") : object "cpaas-system"/"vela-core-admission" not registered

It has the same error with #105204, but the k8s 1.23.13 we used have fixed the issue with the PR #108756.

It appears that the PR haven’t totally fixed the issue. The cause may be if the pod is deleted when the volume manager is setting up the volume of the pod, the syncPod loop in kubelet won’t add the reference count because it’s in terminating state.

So the volume manager will still try to setup the volume of the pod but failed with the “not registed” error.

What did you expect to happen?

The pod should be deleted without the volume setup error.

How can we reproduce it (as minimally and precisely as possible)?

It’s the possibel reproduce steps:

  1. Create a pod with a configmap volume
  2. After the pod is created, delete the pod immediately

Maybe the steps should be runned several times.

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# paste output here
v1.23.13

Cloud provider

None

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
CentOS 7.3

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 15 (10 by maintainers)

Most upvoted comments

@sharad740 that is a different mount error from the “not registered” issue.

@SergeyKanzhelev we’re hitting this issue somewhat frequently in large clusters and it seems to be one of the few sorts of issue like this where restarting kubelet does not resolve the problem and we have to force delete the pod.

E0503 11:35:58.744234 4036992 projected.go:292] Couldn't get configMap browsers-dashboard/kube-root-ca.crt: object "browsers-dashboard"/"kube-root-ca.crt" not registered
E0503 11:35:58.744244 4036992 projected.go:198] Error preparing data for projected volume kube-api-access-dssjd for pod browsers-dashboard/session-agent-bc77c896-scv2f: object "browsers-dashboard"/"kube-root-ca.crt" not registered

This is on kubernetes v1.27.13

It seems to often happen for pods in the Terminating state for us and impacts all of the secret and configmap volumes, but no others.

I fixed my this error

20m (x16 over 36m)       Warning   FailedMount                    Pod/frappe-bench-mariadb-0                                 MountVolume.SetUp failed for volume "pvc-88b8fbdf-42e4-4a2e-9290-
0b823bf677fa" : mount failed: exit status 32                                                                                                                                                  
Mounting command: mount                                                                                                                                                                       
Mounting arguments: -t nfs 10.0.2.10:/home/sharad/nfs/default/erpnext-data-frappe-bench-mariadb-0-pvc-88b8fbdf-42e4-4a2e-9290-0b823bf677fa /var/lib/kubelet/pods/61cf3bbe-21cc-4b98-b698-9f9ed
c83900f/volumes/kubernetes.io~nfs/pvc-88b8fbdf-42e4-4a2e-9290-0b823bf677fa                                                                                                                    
Output: mount: /var/lib/kubelet/pods/61cf3bbe-21cc-4b98-b698-9f9edc83900f/volumes/kubernetes.io~nfs/pvc-88b8fbdf-42e4-4a2e-9290-0b823bf677fa: bad option; for several filesystems (e.g. nfs, c
ifs) you might need a /sbin/mount.<type> helper program.

by installing nfs-common in my worker node

sudo apt install -y nfs-common

Hope you don’t have such silly mistake