Deleting the datastore where a content library is hosted is probably not the best idea

by Apr 14, 2022Content Library

Deleting the datastore where a content library is hosted is probably not the best idea but … yes stupid error and now what. If you are not faint of heart (and now how to take a snapshot), you can rectify this. You should contact GSS as there is not documented solution and this might break.

Take a snapshot and verify if the vCenter backups are in a healthy status. Yes? Ok go ahead.

Log on to the vCenter and create a new Content Library and name it ‘i-made-an-error’. Use the new datastore you want to use and keep the rest of the settings default as these don’t really matter.

Open an SSH session to the vCenter and connect to the Postgress DB ‘VCDB’

psql -d VCDB -U postgres
ShellSession

To show which tables are present within the database:

\d
SQL

Show an overview of the Content Libraries added ( make sure to add the trailing ;):

SELECT id,name FROM cl_library;
SQL

Now that we have an overview of the Content Libraries, with the one that is throwing an error highlighted.

Show the Content Library entries in the vCenter database
Find the content library id

In the following overview we find the library id from the new Content Library we just added and also the corresponding storage id.

SELECT * FROM cl_library_storage;
SQL

Database Content Library storage ids
Find the content library storage id

I will update the storage id from the faulty one we found on the previous screenshot with the one we found for the new Content Library.

UPDATE cl_library_storage
SET storage_id = 'ae80d942-d7e2-4ab8-b0c1-93405ff4db38'
WHERE library_id = '6c7851ed-6166-44b9-b439-5bcd2f9742eb';
ShellSession

Update the storage id for the faulty Content Library
Update the storage for the content library

There are a couple of places that helped me in solving this:

https://communities.vmware.com/t5/VMware-vCenter-Discussions/Content-library-item-delete-issue/td-p/2266050

https://tinkertry.com/how-to-remove-vmware-vsphere-zombie-datastore

https://vmninja.wordpress.com/2019/04/05/remove-inaccessible-datastore-from-inventory/