josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
538 stars 154 forks source link

Error: Failed to grow boot disk: Process exited with status 255 #172

Closed rastro-dev closed 2 years ago

rastro-dev commented 2 years ago

Having issue with creating a new VM on ESXi host. Not trying anything special. Checked the terraform docs and this tool's docs and don't see why this is happening. I can confirm that the VM is registered with ESXi and the datastore folder is created. However the VM seems to be in a "failed" state. The setup is local ESXi with Ubuntu 20.04 as the terraform driver. Any ideas where I should look next. Thanx!

Here is the DEBUG stack.

[DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-esxi_remote_cmds.go:83: [runRemoteSshCommand] cmd:/vim-cmd vmsvc/device.getdevices | grep -A10 'key = 2000'|grep -m 1 fileName/ [DEBUG] provider.terraform-provider-esxi_v1.10.2: stdout:/Insufficient arguments./ [DEBUG] provider.terraform-provider-esxi_v1.10.2: stderr:/Process exited with status 1/ [DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-guest_functions.go:62: [getBootDiskPath] Failed get boot disk path: Insufficient arguments. [DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-virtual-disk_functions.go:110: [growVirtualDisk] [DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-virtual-disk_functions.go:136: [virtualDiskREAD] Begin [DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-virtual-disk_functions.go:146: [virtualDiskREAD] len=1 cap=1 [Failed get boot disk path:] [DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-virtual-disk_functions.go:118: [growVirtualDisk] currentDiskSize:0 new_size:45 fullPATH: Failed get boot disk path: [DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-esxi_remote_cmds.go:61: [runRemoteSshCommand] :grow disk [DEBUG] provider.terraform-provider-esxi_v1.10.2: pid-266905-esxi_remote_cmds.go:83: [runRemoteSshCommand] cmd://bin/vmkfstools -X 45G "Failed get boot disk path:"/ [DEBUG] provider.terraform-provider-esxi_v1.10.2: stdout:/Failed to extend disk : The system cannot find the file specified (25)./ [DEBUG] provider.terraform-provider-esxi_v1.10.2: stderr:/Process exited with status 255/ [ERROR] vertex "esxi_guest.vmtest01" error: Failed to grow boot disk: Process exited with status 255

rastro-dev commented 2 years ago

It seems that the syntax between ESXi versions has changed. I was trying the plugin on 6.0 and 7.0, and the 6.0 was the one that is failing. Perhaps there should be a note that 6.0 is not supported. If there is such a note, please disregard my comment. Thanx :)

TallFurryMan commented 2 months ago

I am seeing this issue now on an ESXi 7.0.3.

The reason this fails is because the key identifier of the virtual disk to grow is searched for with the hardcoded values 2000, 3000 and 16000.

In my case, the virtual disk received key = 2001.

      (vim.vm.device.VirtualDisk) {                                                                                                        
         key = 2001,                                                
         deviceInfo = (vim.Description) {                           
            label = "Hard disk 1",                                                                                                         
            summary = "2,097,152 KB"                               
         },                                  
         backing = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) {
            fileName = "[slow] storage1/storage1_3.vmdk",                                                                                  
            datastore = 'vim.Datastore:61b21053-6af12854-cc27-6cb3110fe43c',                                                               
            backingObjectId = "",              
            diskMode = "persistent",                                                                                                       
            split = false,                                                                                                                 
            writeThrough = false,                                                                                                          
            thinProvisioned = true,                                
            eagerlyScrub = false,                                                                                                          
            uuid = "6000C293-13fe-e4af-cb6c-72e104c11f52",                                                                                 
            contentId = "f1441bf4567a48acb7971b9b7a7f7c26",                                                                                
            changeId = <unset>,                                     
            parent = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) null,                                                                 
            deltaDiskFormat = <unset>,    
            digestEnabled = false,     
            deltaGrainSize = <unset>,                              
            deltaDiskFormatVariant = <unset>, 
            sharing = "sharingNone",                               
            keyId = (vim.encryption.CryptoKeyId) null,                                                                                     
            cryptoIntegrityProtectionType = <unset>
         },                                       
         connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null,                                                                                                                                                                                                                 
         slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null,                                                                                                                                                                                                                    
         controllerKey = 1000,                                                                                                                                                                                                                                                         
         unitNumber = 1,                                                                                                                                                                                                                                                               
         numaNode = <unset>,                                                                                                                                                                                                                                                           
         capacityInKB = 2097152,                                                                                                                                                                                                                                                       
         capacityInBytes = 2147483648,                                                                                                                                                                                                                                                 
         shares = (vim.SharesInfo) {                                                                                                                                                                                                                                                   
            shares = 1000,                                                                                                                                                                                                                                                             
            level = "normal"                                                                                                                                                                                                                                                           
         }, 
         storageIOAllocation = (vim.StorageResourceManager.IOAllocationInfo) {
            limit = -1, 
            shares = (vim.SharesInfo) {
               shares = 1000, 
               level = "normal"
            }, 
            reservation = 0
         }, 
         diskObjectId = "8668-2001", 
         vFlashCacheConfigInfo = (vim.vm.device.VirtualDisk.VFlashCacheConfigInfo) null, 
         iofilter = <unset>, 
         vDiskId = (vim.vslm.ID) null, 
         virtualDiskFormat = <unset>, 
         nativeUnmanagedLinkedClone = false, 
         independentFilters = <unset>
      }, 

I worked around the issue by adding a single VirtualSCSI hardware in the OVF template, no vmware.sata.ahci nor IDE controller and connect a single disk to it. This provides the following device, which has the expected key value in its device list:

      (vim.vm.device.ParaVirtualSCSIController) {
         key = 1000,                  
         deviceInfo = (vim.Description) {    
            label = "SCSI controller 0", 
            summary = "VMware paravirtual SCSI"
         },                           
         backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
         connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
         slotInfo = (vim.vm.device.VirtualDevice.PciBusSlotInfo) {
            pciSlotNumber = 160          
         },                       
         controllerKey = 100, 
         unitNumber = 3,                                                                                                                   
         numaNode = <unset>,           
         busNumber = 0,            
         device = (int) [                                 
            2000                       
         ], 
         hotAddRemove = true,                                     
         sharedBus = "noSharing",     
         scsiCtlrUnitNumber = 7    
      },                               

This said, instead of relying on keys, searching for disks using the hardware tree and supporting more than one disk would be great! :+1: