13 August 2015

Orphaned vmdk search return exception on large Datastores

One of the challenges working with Vmware vcenter is keeping clean and healthy datastores. Making sure only vmdk files registered with active VMs is stored on Datastores is one example.
For this purposes there are numerous scripts around that will compare the files of registered VMs with the actual list of vmdk files found in a Datastore
Examples:


There is however one problem no one seem to be able to address at all accross all these scripts. When you search "very" large datastores and the esxcli / powercli have been running for 15 minutes the script get an exception. (Our VDI linkedclone datastore is very large)
Exception calling "SearchDatastoreSubFolders" with "2" argument(s): "An error o
ccurred while communicating with the remote host."
At xxxxx
+     $searchResult = $dsBrowser.SearchDatastoreSubFolders <<<< ($rootPath, $se
archSpec)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException".

I noticed the exception message was about the remote host so I figured it must be vCenter / ESXi related.

Based on above finding I found this vmware KB article that describe how to increase the timeout for tasks to vCenter and ESXCLI to much more than the default 15 minutes. I implemented the KB article on my vCenter server and on all the ESXi hosts in the cluster. This did the trick for me and I can now complete the datastore search. More specific I'm now able to complete this line of code from the scripts without the exception:
$xxx.SearchDatastoreSubFolders($rootPath, $searchSpec)

I will not list my specific actions as they are covered in the KB article. However the article doesn't mention that the vpxa.cfg file is read only on the ESXi 5.5 host so you need to run the following to get write access
chmod u+w /etc/vmware/vpxa/vpxa.cfg

I hope this makes sense for everyone.
Please comment if you have any questions or feedback.

No comments:

Post a Comment