Error: "Storage policy "############" cannot be deleted since it is currently in use." when detaching storage policy from Organization VDCs
search cancel

Error: "Storage policy "############" cannot be deleted since it is currently in use." when detaching storage policy from Organization VDCs

book

Article ID: 371259

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • Unable to delete a storage policy using the Remove button in the UI found under Resources > Cloud Resources > Organization VDCs > Organization VDC Name > Policies > Storage.
  • Storage policy shows some or no usage as per the UI metrics.
  • Tenant shows that the wrong policy is still in use even though it shows as 0GB in use.

Environment

  • VMware Cloud Director 10.5.x
  • VMware Cloud Director 10.6.x

Cause

The removal of a storage policy is prevented if tenant objects (vApps, vApp templates, or Media) or organization catalogs backed by a specific organization VDC maintain dependencies on the target storage policy.

Resolution

To resolve the issue, any objects leveraging the storage policy needs to be identified and unlinked. Any stale vApps/vApp templates/media can be identified from the database and then verified in the UI with the steps below:

  1. Note the name of the affected OVDC and the storage policy to-be-removed. The scripts listed in Step 3 and 4 will need these names and have to be replaced accordingly.
  2. Connect to the VCD database via SSH or pgAdmin.

    • SSH to any of the appliance nodes
    • Run the command: sudo -u postgres psql vcloud

  3. To find the list of vApps or vApp templates referencing the storage policy available on the tenant

    SELECT
    vapp_vm.name AS vapp_vm_name,
    vm_container.name as vapp_name,
    vm_container.sg_type as type,
    vm.moref as moref,
    vapp_vm_sclass_metrics.storage_used_mb
    FROM vapp_vm_sclass_metrics
    LEFT JOIN vapp_vm ON vapp_vm.id = vapp_vm_sclass_metrics.vapp_vm_id
    LEFT JOIN vm_container ON vm_container.sg_id = vapp_vm.vapp_id
    left join vm on vm.id = vapp_vm.svm_id
    JOIN vdc_logical_resource ON vdc_logical_resource.id = vapp_vm_sclass_metrics.storage_class_lr_id
    JOIN org_prov_vdc ON org_prov_vdc.id = vdc_logical_resource.vdc_id
    WHERE org_prov_vdc.name = 'Organization VDC Name' AND vdc_logical_resource.name = 'Storage policy to-be-removed';

    Note: type column with value 1 would mean it is a normal vApp and value 2 would mean it is a vApp template.

  4. To find the list of media items that may still be present in the storage profile to be removed.

    SELECT
    org_prov_vdc.name AS org_vdc_name,
    logical_disk.id AS logical_disk_id,
    logical_disk.name AS logical_disk_name,
    logical_disk.logical_disk_type,
    logical_disk.creation_status AS logical_creation_status,
    COALESCE((logical_disk.size_bytes::numeric / 1048576.0), 0::numeric) AS storage_used_mb
    FROM logical_disk
    LEFT JOIN ldisk_storage_class_join ON logical_disk.id = ldisk_storage_class_join.logical_disk_id
    LEFT JOIN ldisk_fo_join ON logical_disk.id = ldisk_fo_join.logical_disk_id
    LEFT JOIN vm_disk ON vm_disk.disk_id = ldisk_fo_join.fo_id
    LEFT JOIN org_prov_vdc ON org_prov_vdc.id = logical_disk.org_vdc_id
    LEFT JOIN vdc_logical_resource ON vdc_logical_resource.id = ldisk_storage_class_join.storage_class_id
    where org_prov_vdc.name like '%Organization VDC Name%';

  5. For the catalogs in the organizations, verify the Storage Policies settings as per the documentations below:

  6. Migrate the VMs/vApps/media identified in Steps 3, 4 or change the storage policy on them.

Edit the Default Storage Policy of a vApp Template
Edit Virtual Machine Properties in the VMware Cloud Director Tenant Portal

Edit a Named Disk

Note: Outputs in Step 3 & 4 might show stale items which are not present in UI anymore.

If the UI method(s) does not work, contact VMware Cloud Director Support and note this Article ID (371259) in the problem description.For more information, see How to Submit a Support Request.

Additional Information