Pods stuck in ContainerCreating status with Error: "volume ID: does not appear staged..."
search cancel

Pods stuck in ContainerCreating status with Error: "volume ID: does not appear staged..."

book

Article ID: 378751

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service

Issue/Introduction

  • Pods remain in a ContainerCreating state.

  • Describing the pod  indicates volume ID "does not appear staged" to the global mount path.

Warning  FailedMount  1s    kubelet            MountVolume.SetUp failed for volume "pvc-<>" : rpc error: code = FailedPrecondition desc = volume ID: "<volume-id>" does not appear staged to "/var/lib/kubelet/plugins/kubernetes.io/csi/csi.vsphere.vmware.com/<>/globalmount"

  • The kubectl get pv,pvc,volumeattachment command shows the PV and PVC in a Bound state, but the VolumeAttachment persists even after pod deletion.

kubectl get pv,pvc,volumeattachment -n <namespace>

For example:

kubectl get pv,pvc,volumeattachment -n <namespace>
NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                     STORAGECLASS            REASON   AGE
persistentvolume/pvc-########-####-####-####-############   1Gi        RWO            Retain           Bound    default/claim_name        storage_class_name               2d3h

NAME                                    STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS            AGE
persistentvolumeclaim/claim_name        Bound    pvc-########-####-####-####-############   1Gi        RWO            storage_class_name      2d

NAME                                                                                                   ATTACHER                 PV                                         NODE          ATTACHED   AGE
volumeattachment.storage.k8s.io/csi-################################################################   csi.vsphere.vmware.com   pvc-########-####-####-####-############   workload-<>   true       3m53s

  • The issue impacts Persistent Volumes (PVs) using the csi.vsphere.vmware.com StorageClass with reclaimPolicy set to Retain.

    kubectl describe sc <storage_class_nanme> -n <namespace>

    allowVolumeExpansion: true
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: storage_class_name
    provisioner: csi.vsphere.vmware.com
    reclaimPolicy: Retain
    volumeBindingMode: Immediate

  • CSI pods in the vmware-system-csi namespace appear healthy, yet volume operations fail.

  • Worker node inspection via df -h | grep <pv-name> returns no results despite the VolumeAttachment metadata indicating the volume is attached.

  • The directory /var/lib/kubelet/pods/<pod-uuid>/volumes/kubernetes.io~csi/ remains empty for the affected volume.

df -h | grep pvc-########-####-####-####-############

ls -lrt /var/lib/kubelet/pods/########-####-####-####-############/volumes/kubernetes.io~csi/

total 0

  • Kubelet logs on the affected node contain rpc error: code = FailedPrecondition during volume setup.

    journalctl -u kubelet | grep <pod-name>

Environment

  • VMware vSphere CSI Driver

  • VMware vSphere Kubernetes Service

Cause

A CSI volume error occurs when the VolumeAttachment object persists without a valid filesystem mount on the scheduled node. The CSI driver interprets the existing object as a successful attachment, preventing subsequent mount attempts and leaving Pods stuck in ContainerCreating.

Resolution

  1. Identify the Deployments or StatefulSets using the affected PVC: 

    kubectl get po -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{.spec.volumes[*].persistentVolumeClaim.claimName}{"\n"}{end}' | grep <pvc-name>

  2. Scale the identified resources to zero replicas: 

    kubectl scale deploy <deployment-name> -n <namespace> --replicas=0
    kubectl scale sts <statefulset-name> -n <namespace> --replicas=0

  3. Delete the stale VolumeAttachment object manually if it doesn't get deleted automatically: 

    kubectl delete volumeattachment <attachment-name>

    Note: Make sure it doesn't get recreated. If it gets recreated, most likely there's still some Pod mounting the PVC. Look for it and scale down the associated Deployment/StatefulSet.

  4. Scale the Deployment or StatefulSet back to the original replica count.

    kubectl scale deploy <deployment-name> -n <namespace> --replicas=0
    kubectl scale sts <statefulset-name> -n <namespace> --replicas=0

  5. Verify the pods transition to Running and confirm the creation of a new VolumeAttachment.

  6. If the issue persists, scale the CSI controller pods in the Supervisor cluster to refresh the controller state:

    kubectl scale deployments vsphere-csi-controller -n vmware-system-csi --replicas=0
    kubectl scale deployments vsphere-csi-controller -n vmware-system-csi --replicas=2

  7. Delete the CSI node pod on the affected worker node within the guest cluster to clear the stale cache and trigger a driver restart:

    kubectl get pods -A -o wide | grep csi
    kubectl delete pod <pod_name> -n vmware-system-csi