How to remove a stale Content Library from vCenter Server Appliance when the datastore it resided on is no longer accessible
search cancel

How to remove a stale Content Library from vCenter Server Appliance when the datastore it resided on is no longer accessible

book

Article ID: 326242

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

Symptoms:
  • a Content Library should be deleted

  • When attempting to delete the Content Library using the vSphere Client, the task fails

  • the Backing datastore the Content Library resided on is no longer accessible, has been unmounted or removed



Environment

VMware vCenter Server 7.0.x
VMware vCenter Server 6.x

Cause

Part of the deletion process for a Content Library is cleaning up the Content Library files which reside on a VMFS datastore.
If this part of the workflow fails, the deletion process will run into an error.

Resolution

To remove the Content Library from vCenter, connect to the vCenter Database using to psql tool in the VCSA:

# /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres


Then:

  1. In psql run the following query to find the ID of the Content Library that it to be deleted (replace <cl_name> with the name of the Content Library):
    # select id,name from cl_library where name = '<cl_name>';
  2. Use the Content Library ID to find the storage ID:
    # select * from cl_library_storage where library_id = '<ID from step 1>';
  3. Using the 2 IDs, delete the Entries for the Content Library:
    # delete from cl_library_storage where library_id = '<ID from step 1>';
    # delete from cl_storage where id = '<storage_id from step 2>';
    # delete from cl_library where name = '<cl_name>';
  4. Exit psql using \q and restart the vCenter Services:
    # service-control --stop --all && service-control --start --all



Additional Information

Impact/Risks:

The steps in this article do make changes in the vCenter database. Please ensure that a fresh backup or at the very least an offline snapshot (as in a snapshot of the vCenter in powered off state) exists.
If the vCenter Server is a member of a Linked Mode group, please be aware that backups / offline snapshots need to be taken for all of ELM nodes. Should a restore be required, all nodes need to be restored, otherwise there will be inconsistencies in the Linked Mode replication.