Error "Attach failed for volume "pvc-########-####-####-####-###########" : PersistentVolume "pvc-########-####-####-####-###########" is marked for deletion" in Pods
search cancel

Error "Attach failed for volume "pvc-########-####-####-####-###########" : PersistentVolume "pvc-########-####-####-####-###########" is marked for deletion" in Pods

book

Article ID: 428729

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid Management

Issue/Introduction

  • The pods  are stuck in container creating status due to the attached PVC volume not being available.

tanzu-system-monitoring   alertmanager-#################                                0/1     ContainerCreating   0                  3d20h   <none>            <Workder node name>     <none>           <none>
tanzu-system-monitoring   prometheus-#####################                          0/2     ContainerCreating   0                  3d20h   <none>             <Worker node name>      <none>           <none>

  • kubectl describe pod <pod name> -m n <name space>

Events: 

         Type     Reason                                Age                               From                                                        Message
  ----     ------              ----                     ----                     -------
  Warning  FailedMount                33m (x496 over 3d20h)      kubelet                                                     Unable to attach or mount volumes: unmounted volumes=[storage-volume], unattached volumes=[storage-volume kube-api-access-#######storage-volume]: timed out waiting for the condition
  Warning  FailedMount                21m (x460 over 3d20h)      kubelet                                                     Unable to attach or mount volumes: unmounted volumes=[storage-volume], unattached volumes=[kube-api-access-#######storage-volume config-volume]: timed out waiting for the condition
  Warning  FailedAttachVolume   3m3s (x2726 over 3d20h)   attachdetach-controller  AttachVolume    Attach failed for volume "pvc-########-####-####-####-###########" : PersistentVolume "pvc-########-####-####-####-###########" is marked for deletion
  Warning  FailedMount               89s (x1491 over 3d20h)      kubelet                                                     Unable to attach or mount volumes: unmounted volumes=[storage-volume], unattached volumes=[config-volume kube-api-access-#######storage-volume]: timed out waiting for the condition    

   

  • The Persistent volumes are stuck in terminating status. 


    kubectl get pv -A | grep Term    p -i Terminating
    pvc-########-####-####-####-###########   2Gi         RWO            Delete           Terminating   tanzu-system-monitoring/alertmanager                                <Storage Class name>          2y66d
    pvc-########-####-####-####-###########   150Gi      RWO            Delete           Terminating   tanzu-system-monitoring/prometheus-server                       <Storage Class name>           2y66d

  • The attachment status of the volumes show as false.

    kubectl get volumeattacments

                                                         NAME                                                                                 ATTACHER                                           PV                                                  NODE                                        ATTACHED   AGE
    csi-###########################################################           csi.vsphere.vmware.com  pvc-########-####-####-####-###########    <Worker node name>                         False           3d20h
    csi-###########################################################           csi.vsphere.vmware.com  pvc-########-####-####-####-###########    <Worker node name>                         False          3d17h

Environment

2.x

Cause

The  backend vSphere volumes associated with the Persistent Volume in Kubernetes have been deleted or are no longer accessible.

 

Resolution

  1. Remove the stale Volume attachments

    kubectl delete volumeattachment csi-########################################################### 

  2. Force Delete the stuck PVC

    kubectl delete pvc <pvc name> -n <name space> --force --grace-period=0

  3. Remove the finalizer that blocks the deletion

    kubectl patch pvc <pvc-name> -n tanzu-system-monitoring -p '{"metadata":{"finalizers":null}}'

  4. Delete the pods

    kubectl delete pod -n <namespace>

  5. Monitor if the pods are getting recreated successfully.

    kubectl get pod -n <namespace> -w