Persistent volume fails to attach due to missing volumeID
search cancel

Persistent volume fails to attach due to missing volumeID

book

Article ID: 320790

calendar_today

Updated On:

Products

VMware vCenter Server 8.0 VMware vSphere ESXi

Issue/Introduction

  • The CSI volume attachment receives the following error while attaching a Persistent Volume to a Kubernetes node:

    Status:
      Attach Error:
        Message:  rpc error: code = Internal desc = failed to attach disk: "####" with node: "####" err failed to attach cns volume: "####" to node vm: "VirtualMachine:vm-## [VirtualCenterHost: ####, UUID:####, Datacenter: Datacenter [Datacenter: Datacenter:datacenter-##, VirtualCenterHost: ####]]". fault: "(*types.LocalizedMethodFault)(0xc00000000)({\n DynamicData: (types.DynamicData) {\n },\n Fault: (types.CnsFault) {\n  BaseMethodFault: (types.BaseMethodFault) <nil>,\n  Reason: (string) (len=88) \"The input volume #### is not registered as a CNS volume.\"\n },\n LocalizedMessage: (string) (len=35) \"fault.CnsNotRegisteredFault.summary\"\n})\n". opId: "##"
        Time:     YYYY:MM:DD
      Attached:   false
      Detach Error:
        Message:  rpc error: code = Internal desc = volumeID "####" not found in QueryVolume

  • The PV is not listed on the vCenter UI under "Container Volumes".

Environment

  • VMware Tanzu Kubernetes Grid
  • vSphere Kubernetes Service
  • Cloud Native Storage

Cause

General discrepancies between the datastore and the CNS database cause this issue.

Resolution

Prerequisites:

  1. Before rebuilding the catalog, review the KB article - Reconciling Discrepancies in the Managed Virtual Disk Catalog.

  2. Ensure no other CNS/FCD operations are running on the datastore throughout this procedure.

  3. If the hosts run vSAN, first run the following command on ALL hosts in the vSAN cluster:
    esxcfg-advcfg -s 1 /VSAN/IgnoreClusterMemberListUpdates

    This prevents vCenter from removing any hosts from the cluster when they stop communicating (due to stopping hostd).
    Once the procedure in this article is completed, re-enable vCenter member updates by running:
    esxcfg-advcfg -s 0 /VSAN/IgnoreClusterMemberListUpdates

  4. If the datastore is mounted on hosts of more than 1 VC (i.e., shared among VCs), SSH to one of the ESXi hosts and run:
    find /vmfs/volumes/<datastore>/catalog/journal -name "*.xaction"
    If the output contains files, do not rebuild the catalog.

Steps to Rebuild the Catalog:

  1. Identify all affected datastores.

  2. Identify all ESXi hosts connected to the datastores for which the FCD catalog is being rebuilt.

  3. Pick one host, SSH into it, and execute the following commands:

    1. Stop the hostd service:
      1. /etc/init.d/hostd stop

    2. For each identified datastore, move the catalog folder to a backup folder:
      1. mkdir /tmp/<datastore>-catalog-bkp(or any other temporary directory in any other datastore)
      2. cd /vmfs/volumes/<datastore>/catalog
      3. mv $(ls | grep -v journal) /tmp/catalog
      4. ls /tmp/catalog #(make sure all files are copied)

    3. Start the hostd service:
      1. /etc/init.d/hostd start

  4.  SSH to other hosts on which the datastore is mounted and execute the following command to restart hostd:
    /etc/init.d/hostd restart
     Alternatively, run the following to avoid a hostd restart:
    /usr/lib/vmware/hostd/bin/notifyDatastore.py -t PreUnmount -d <dsName>

  5. For vCenter Server version 9.0 and above

    1. Enable the vCenter MOB before accessing it.
      Go to VC MOB > content > vStorageObjectManager > ReconcileDatastoreInventoryEx_Task

      The MOB URL format is:
      https://<vcsa- fqdn>/mob/?moid=VStorageObjectManager&method=reconcileDatastoreInventoryEx

    2. Replace the existing spec with the following:
      <spec>
        <datastore type="Datastore">datastore-MOID</datastore>
      </spec>

      Note: To get the datastore MOID, navigate to VC MOB > content >rootFolder > datacenter > datastore > moid
      (or extract "datastore-##" from the URL when the datastore is selected in the vSphere client).

    3. Invoke the task by replacing the datastore MOID in the spec above and wait until it succeeds.

    4. Repeat this for each identified datastore.

  6.   For older releases

    1. Enable the ESXi host MOB before accessing it.

    2. Go to host MOB > ha-vstorage-object-manager > HostReconcileDatastoreInventory_Task
      The MOB URL format is:
      https://<ESXI_host_fqdn/IP>/mob/?moid=ha-vstorage-object-manager&method=reconcileDatastoreInventory

    3. Provide the <datastore-UUID>
      Example: ds:///vmfs/volumes/<datastore-UUID>/ (Found on the summary page of the datastore in the vCenter UI)

    4. Run the reconcile task and wait until it succeeds.

    5. Repeat this for each identified datastore.

  7.  SSH into the host selected for the steps above. Verify the catalog folder reappears for all datastores processed in Step 1:

    1. ls /vmfs/volumes/<datastore-path>/catalog   
       
    2. Verify that vclock is created in the format of "vclock-" for all the datastores:
      ls /vmfs/volumes/<datastore-path>/catalog     

    3. Verify tidy file is created for all datastores. The below command should return a file named "1.dat”
      ls /vmfs/volumes/<datastore-path>/catalog

  8. For ESXi hosts version 9.0 and above

    1. Trigger CNS fullSync (for VC version 8.0 and above), by following the below instructions:

    2. SSH to the vCenter Server and execute the following command:
      1. psql -U postgres -d VCDB

    3. Get the required datastore URL from vpx_ds_info or cns.vpx_storage_datastore_info;
      1. select name, url from vpx_ds_info;
      2. select * from cns.vpx_storage_datastore_info;
      3. update cns.vpx_storage_datastore_info set vclock=-1 where datastore_url='<>';
      4. delete from cns.volume_info where datastore='<>';

    4. Restart vsan-health service
      1. vmon-cli --restart vsan-health

    5. Wait for Full Sync to complete. The following log lines appear in /var/log/vmware/vsan-health/vsanvcmgmtd.log:
      info vsanvcmgmtd[219935] [vSAN@6876 sub=CnsSync] Sync all datastores ...
      info vsanvcmgmtd[219935] [vSAN@6876 sub=CnsSync] Sync ds:///vmfs/volumes/<ds-uuid>: startVClock = 0, fullSync = true
      info vsanvcmgmtd[219935] [vSAN@6876 sub=CnsSync] Synced all datastores

    6. Confirm that the CNS database is updated with the correct vclock values:
      1. psql -U postgres -d VCDB
      2. select * from cns.vpx_storage_datastore_info;
      3. select * from cns.volume_info where datastore='<>';

  9. For older ESXi hosts

    1. If the database content is not getting updated even after some time, and the database is showing old content, trigger a sync for the "StorageLifecycleManager".
      1. https://<VCIP>/vslm/mob//?moid=StorageLifecycleManager&method=VslmSyncDatastore
      2. The datastore URL format is "ds:///vmfs/volumes/##### - ###### - ######". (Found on the summary page of the datastore in the vCenter UI)
      3. Set "fullSync=true"
      4. "fcd Id" can be blank

    2. Once this is done, wait for some time for data sync between SPS and CNS. After this sync, the Persistent volume appears in vCenter's CNS UI.

Additional Information