knife-vsphere icon indicating copy to clipboard operation
knife-vsphere copied to clipboard

How to find the slowness on knife vsphere vm vmdk add?

Open rdeavila opened this issue 3 years ago • 1 comments

Hello!

Scenario:

I'm seen a very annoying slowdown on the knife vsphere vm vmdk add command. In one datacenter, this command runs with no delay; in another, I've seen times between 4 and 10 minutes to complete. Using -VVV I found the slowness: it's on vsphere_vm_vmdk_add.rb between lines 85 and 96.

Of course, the problem is on my vsphere, but how can I find who is the real culprit on vsphere API? How I debug this file using my production server?

Thanks.

rdeavila avatar Jan 12 '21 12:01 rdeavila

Hi, that code is not great. It's looking at all the files in the datastore to find ones associated with the VM, and each trip through the loop is probably going to involve an API call back to vsphere. You could validate this with some puts lines, say right before that if on line 91.

If you can run the command within the datacenter rather than remotely that'll speed things up. Someone more conversant with the vsphere API might know a way to get the same data but faster. Or maybe the search helpers could be used to reduce the round trips back to the server.

swalberg avatar Jan 12 '21 13:01 swalberg