Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsphere: panic: interface conversion: interface {} is *schema.Set #358

Open
weakcamel opened this issue Mar 9, 2023 · 3 comments
Open
Labels
Type: Bug Something isn't working

Comments

@weakcamel
Copy link

weakcamel commented Mar 9, 2023

General information:

  • Operating System: Linux Ubuntu Bionic (18.04)
  • Terracognita version / tag: 0.8.2
  • Did you build Terracognita from sources or did you use the Docker image: Downloaded a binary from Github releases.

Describe the bug:

Terracognita crashes on importing a vsphere VM

Log message

$ terracognita  vsphere --vsphereserver vsphere.example.com --soap-url vsphere.example.com --username weakcamel --password $PASS --hcl foo -i vsphere_virtual_machine
We are about to remove all content from "foo", are you sure? Yes/No (Y/N):
y
Starting Terracognita with version v0.8.2
Importing with filters:
	Tags:    [],
	Include: [vsphere_virtual_machine],
	Exclude: [],
	Targets: [],
Importing vsphere_virtual_machine [4/347]panic: interface conversion: interface {} is *schema.Set, not map[string]interface {}

goroutine 1 [running]:
github.com/cycloidio/terracognita/provider.(*resource).Read(0xc000cb0750, 0xc000426f50)
	/tmp/build/6b18b934/code/provider/resource.go:304 +0xa54
github.com/cycloidio/terracognita/provider.Import.func1()
	/tmp/build/6b18b934/code/provider/import.go:122 +0x29
github.com/cycloidio/terracognita/util.Retry(0xc000fc7a50, 0x3, 0x2)
	/tmp/build/6b18b934/code/util/retry.go:23 +0x43
github.com/cycloidio/terracognita/util.RetryDefault(...)
	/tmp/build/6b18b934/code/util/retry.go:52
github.com/cycloidio/terracognita/provider.Import({0x1286afb8, 0xc0000760c0}, {0x12aa4238, 0xc000968280}, {0x1286c608, 0xc000908c30}, {0x0, 0x0}, 0xc000426f50, {0x126e56a0, ...})
	/tmp/build/6b18b934/code/provider/import.go:122 +0x1385
github.com/cycloidio/terracognita/cmd.importProvider({0x1286afb8, 0xc0000760c0}, {0x126dcdc0, 0xc000495c80}, {0x12aa4238, 0xc000968280}, {0x0, 0x0, 0x0})
	/tmp/build/6b18b934/code/cmd/root.go:326 +0x590
github.com/cycloidio/terracognita/cmd.glob..func13(0x1d6a10a0, {0xc0002e6a80, 0xc, 0xc})
	/tmp/build/6b18b934/code/cmd/vsphere.go:55 +0x2ac
github.com/spf13/cobra.(*Command).execute(0x1d6a10a0, {0xc0002e69c0, 0xc, 0xc})
	/tmp/build/6b18b934/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0x1d6a0420)
	/tmp/build/6b18b934/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
	/tmp/build/6b18b934/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
main.main()
	/tmp/build/6b18b934/code/main.go:11 +0x25

Additional context

vSphere appliance version 7.0.3

@xescugc
Copy link
Member

xescugc commented Mar 30, 2023

We are not able to reproduce it on our side, could you perhaps provide more information around it?

This is happening when we try to read the tags of the Resource if you check the TerraCognita logs (so see where they are you can run terracognita -h and check the flag --log-file and the default value is where they are) so then you could check the resource and on the Provider console maybe check which are the tags or which is the format they have so it could help me fix the issue :).

I've opened #370 which does not fix the issue itself but it'll make it go away on your specific usecase :)

@weakcamel
Copy link
Author

We are not able to reproduce it on our side, could you perhaps provide more information around it?

I've collected the debug logs (log file just saved the verbose ones)

export TF_LOG=TRACE
$ terracognita  vsphere --vsphereserver vsphere.example.com --soap-url vsphere.example.com --username weakcamel --password $PASS --hcl foo -i vsphere_virtual_machine --log-file test.txt --debug
We are about to remove all content from "foo", are you sure? Yes/No (Y/N):
y
ts=2023-03-31T08:23:01.102827441Z caller=provider.go:47 func=vsphere.Client msg="configuring TF Client"
2023-03-31T09:23:01.102+0100 [DEBUG] Cached SOAP client session data not valid or persistence not enabled, new session necessary
2023-03-31T09:23:01.102+0100 [DEBUG] Creating new SOAP API session on endpoint vsphere.example.com
2023-03-31T09:23:01.176+0100 [DEBUG] SOAP API session creation successful
2023-03-31T09:23:01.176+0100 [DEBUG] VMWare vSphere Client configured for URL: vsphere.example.com
2023-03-31T09:23:01.176+0100 [DEBUG] Setting up REST client
2023-03-31T09:23:01.456+0100 [DEBUG] CIS REST client configuration successful
ts=2023-03-31T08:23:01.473640306Z caller=provider.go:65 func=vsphere.NewProvider msg="loading TF client"
2023-03-31T09:23:01.474+0100 [DEBUG] Cached SOAP client session data not valid or persistence not enabled, new session necessary
2023-03-31T09:23:01.474+0100 [DEBUG] Creating new SOAP API session on endpoint vsphere.example.com
2023-03-31T09:23:01.533+0100 [DEBUG] SOAP API session creation successful
2023-03-31T09:23:01.533+0100 [DEBUG] VMWare vSphere Client configured for URL: vsphere.example.com
2023-03-31T09:23:01.533+0100 [DEBUG] Setting up REST client
2023-03-31T09:23:01.783+0100 [DEBUG] CIS REST client configuration successful
ts=2023-03-31T08:23:01.792865139Z caller=root.go:313 func=cmd.vsphere.RunE msg="initializing HCL writer"
ts=2023-03-31T08:23:01.792969433Z caller=root.go:322 func=cmd.vsphere.RunE msg=importing
ts=2023-03-31T08:23:01.793011769Z caller=root.go:325 func=cmd.vsphere.RunE msg="starting terracognita" version=v0.8.2
ts=2023-03-31T08:23:01.793049343Z caller=import.go:67 func=provider.Import filters="\n\tTags:    [],\n\tInclude: [vsphere_virtual_machine],\n\tExclude: [],\n\tTargets: [],\n"
ts=2023-03-31T08:23:01.793120062Z caller=import.go:79 func=provider.Import resource=vsphere_virtual_machine msg="fetching the list of resources"
ts=2023-03-31T08:23:01.994916841Z caller=import.go:105 func=provider.Import resource=vsphere_virtual_machine id=/London/vm/ct-1049615-4120693.myappliance.example.com total=326 current=1 msg="reading from TF"
2023-03-31T09:23:01.995+0100 [DEBUG] Looking for VM by name/path "/London/vm/ct-1049615-4120693.myappliance.example.com"
2023-03-31T09:23:02.006+0100 [DEBUG] Fetching properties for VM "/London/vm/ct-1049615-4120693.myappliance.example.com"
2023-03-31T09:23:02.018+0100 [DEBUG] Determining number of controllers for VM "/London/vm/ct-1049615-4120693.myappliance.example.com"
2023-03-31T09:23:02.018+0100 [DEBUG] DiskImportOperation: Performing pre-read import and validation of virtual disks
2023-03-31T09:23:02.018+0100 [DEBUG] DiskRefreshOperation: Found controller "controller-1000" for device "disk-1000-0"
2023-03-31T09:23:02.018+0100 [DEBUG] DiskImportOperation: Disk devices order before sort: disk-1000-0
2023-03-31T09:23:02.018+0100 [DEBUG] DiskImportOperation: Disk devices order after sort: disk-1000-0
2023-03-31T09:23:02.018+0100 [DEBUG] DiskImportOperation: Validating disk type and saving
2023-03-31T09:23:02.018+0100 [DEBUG] DiskImportOperation: Discovered disks from import: (key -1 at scsi:0:0)
2023-03-31T09:23:02.018+0100 [DEBUG] DiskImportOperation: Pre-read import and validation complete
2023-03-31T09:23:02.018+0100 [DEBUG] VM UUID for "/London/vm/ct-1049615-4120693.myappliance.example.com" is "423998ba-0fbe-fadd-d48d-bb6906e2c8b6"
2023-03-31T09:23:02.018+0100 [DEBUG] vsphere_virtual_machine (ID = 423998ba-0fbe-fadd-d48d-bb6906e2c8b6): Import complete, resource is ready for read
2023-03-31T09:23:02.029+0100 [DEBUG] vsphere_virtual_machine (ID = 423998ba-0fbe-fadd-d48d-bb6906e2c8b6): Reading state of virtual machine
2023-03-31T09:23:02.029+0100 [DEBUG] Locating virtual machine with UUID "423998ba-0fbe-fadd-d48d-bb6906e2c8b6"
2023-03-31T09:23:02.029+0100 [DEBUG] Using SearchIndex to look up UUID "423998ba-0fbe-fadd-d48d-bb6906e2c8b6"
2023-03-31T09:23:02.040+0100 [DEBUG] VM "/London/vm/ct-1049615-4120693.myappliance.example.com" found for UUID "423998ba-0fbe-fadd-d48d-bb6906e2c8b6"
2023-03-31T09:23:02.040+0100 [DEBUG] Fetching properties for VM "/London/vm/ct-1049615-4120693.myappliance.example.com"
2023-03-31T09:23:02.054+0100 [DEBUG] MOID for VM "/London/vm/ct-1049615-4120693.myappliance.example.com" is "vm-1299309"
2023-03-31T09:23:02.054+0100 [DEBUG] Locating vApp container with ID resgroup-15689
2023-03-31T09:23:02.062+0100 [DEBUG] Locating datastore with ID "datastore-1296653"
2023-03-31T09:23:02.065+0100 [DEBUG] Datastore with ID "datastore-1296653" found
2023-03-31T09:23:02.081+0100 [DEBUG] queryAssociatedProfile: Retrieving storage policy of server object of type [virtualMachine] and key [vm-1299309].
2023-03-31T09:23:02.119+0100 [DEBUG] ReadSCSIBusType: SCSI controller layout for first 1 controllers: lsilogic-1000
2023-03-31T09:23:02.119+0100 [DEBUG] ReadSCSIBusSharing: SCSI controller layout for first 1 controllers: lsilogic-1000
2023-03-31T09:23:02.119+0100 [DEBUG] DiskRefreshOperation: Beginning refresh
2023-03-31T09:23:02.119+0100 [DEBUG] DiskRefreshOperation: Found controller "controller-1000" for device "disk-1000-0"
2023-03-31T09:23:02.120+0100 [DEBUG] DiskRefreshOperation: Disk devices located: disk-1000-0
2023-03-31T09:23:02.120+0100 [DEBUG] DiskRefreshOperation: Current resource set from state: (key -1 at scsi:0:0)
2023-03-31T09:23:02.120+0100 [DEBUG] DiskRefreshOperation: Looking for freshly-created or re-assigned resources to read in
2023-03-31T09:23:02.120+0100 [DEBUG] disk.0 (key -1 at scsi:0:0) (<unknown>): Reading state
2023-03-31T09:23:02.120+0100 [DEBUG] FindVirtualDevice: Looking for device with address scsi:0:0
2023-03-31T09:23:02.120+0100 [DEBUG] FindVirtualDevice: Device found: disk-1000-0
2023-03-31T09:23:02.120+0100 [DEBUG] Locating virtual machine with UUID "423998ba-0fbe-fadd-d48d-bb6906e2c8b6"
2023-03-31T09:23:02.120+0100 [DEBUG] Using SearchIndex to look up UUID "423998ba-0fbe-fadd-d48d-bb6906e2c8b6"
2023-03-31T09:23:02.125+0100 [DEBUG] VM "/London/vm/ct-1049615-4120693.myappliance.example.com" found for UUID "423998ba-0fbe-fadd-d48d-bb6906e2c8b6"
2023-03-31T09:23:02.133+0100 [DEBUG] queryAssociatedProfile: Retrieving storage policy of server object of type [virtualDiskId] and key [vm-1299309:2000].
2023-03-31T09:23:02.142+0100 [DEBUG] disk.0 (key 2000 at scsi:0:0) (ct-1049615-4120693.myappliance.example.com/ct-1049615-4120693.myappliance.example.com.vmdk): Read finished (key and device address may have changed)
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Disk devices after created/re-assigned device search:
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Resource set to write after created/re-assigned device search: (key 2000 at scsi:0:0)
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Looking for devices known in state
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Resource set to write after known device search: (key 2000 at scsi:0:0)
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Probable orphaned disk devices:
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Adding orphaned devices
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Resource set to write after adding orphaned devices: (key 2000 at scsi:0:0)
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Final (sorted) resource set to write: (key 2000 at scsi:0:0)
2023-03-31T09:23:02.142+0100 [DEBUG] DiskRefreshOperation: Refresh operation complete, sending new resource set
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Beginning refresh
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Network devices located: ethernet-0
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Current resource set from state:
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: 1 devices over a 1 unit range
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Looking for freshly-created resources to read in
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Network devices after freshly-created device search: ethernet-0
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Resource set to write after freshly-created device search: (<nil>)
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Looking for devices known in state
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Resource set to write after known device search: (<nil>)
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Probable orphaned network interfaces: ethernet-0
2023-03-31T09:23:02.143+0100 [DEBUG] NetworkInterfaceRefreshOperation: Adding orphaned devices
2023-03-31T09:23:02.143+0100 [DEBUG] network_interface.0 (key 4000 at pci:0:7): Reading state
2023-03-31T09:23:02.143+0100 [DEBUG] FindVirtualDevice: Looking for device with key 4000
2023-03-31T09:23:02.143+0100 [DEBUG] FindVirtualDevice: Device found: ethernet-0
2023-03-31T09:23:02.148+0100 [DEBUG] network_interface.0 (key 4000 at pci:0:7): Read finished (key and device address may have changed)
2023-03-31T09:23:02.148+0100 [DEBUG] NetworkInterfaceRefreshOperation: Resource set to write after adding orphaned devices: (key 4000 at pci:0:7)
2023-03-31T09:23:02.148+0100 [DEBUG] NetworkInterfaceRefreshOperation: Refresh operation complete, sending new resource set
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Beginning refresh
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: CDROM devices located:
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Current resource set from state:
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Looking for freshly-created resources to read in
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: CDROM devices after freshly-created device search:
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Resource set to write after freshly-created device search:
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Looking for devices known in state
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Resource set to write after known device search:
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Probable orphaned CDROM devices:
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Resource set to write after adding orphaned devices:
2023-03-31T09:23:02.148+0100 [DEBUG] CdromRefreshOperation: Refresh operation complete, sending new resource set
2023-03-31T09:23:02.148+0100 [DEBUG] Reading tags for object "vm-1299309"
2023-03-31T09:23:02.330+0100 [DEBUG] Tags for object "vm-1299309": urn:vmomi:InventoryServiceTag:666feea8-f112-403f-a65c-c8c6419b0de0:GLOBAL
2023-03-31T09:23:02.330+0100 [DEBUG] vsphere_virtual_machine (ID = 423998ba-0fbe-fadd-d48d-bb6906e2c8b6): Checking guest networking state
2023-03-31T09:23:02.330+0100 [DEBUG] vsphere_virtual_machine (ID = 423998ba-0fbe-fadd-d48d-bb6906e2c8b6): Primary IP address: 192.168.7.172
2023-03-31T09:23:02.330+0100 [DEBUG] vsphere_virtual_machine (ID = 423998ba-0fbe-fadd-d48d-bb6906e2c8b6): All IP addresses: 192.168.7.172,10.10.10.2,fe80::250:56ff:feb9:f2c1
2023-03-31T09:23:02.330+0100 [DEBUG] vsphere_virtual_machine (ID = 423998ba-0fbe-fadd-d48d-bb6906e2c8b6): Read complete
panic: interface conversion: interface {} is *schema.Set, not map[string]interface {}

goroutine 1 [running]:
github.com/cycloidio/terracognita/provider.(*resource).Read(0xc0005ac900, 0xc00055a930)
	/tmp/build/6b18b934/code/provider/resource.go:304 +0xa54
github.com/cycloidio/terracognita/provider.Import.func1()
	/tmp/build/6b18b934/code/provider/import.go:122 +0x29
github.com/cycloidio/terracognita/util.Retry(0xc000d29a50, 0x3, 0x2)
	/tmp/build/6b18b934/code/util/retry.go:23 +0x43
github.com/cycloidio/terracognita/util.RetryDefault(...)
	/tmp/build/6b18b934/code/util/retry.go:52
github.com/cycloidio/terracognita/provider.Import({0x1286afb8, 0xc00012c000}, {0x12aa4238, 0xc000934400}, {0x1286c608, 0xc00061cc30}, {0x0, 0x0}, 0xc00055a930, {0x126eafe0, ...})
	/tmp/build/6b18b934/code/provider/import.go:122 +0x1385
github.com/cycloidio/terracognita/cmd.importProvider({0x1286afb8, 0xc00012c000}, {0x126dcdc0, 0xc000189f20}, {0x12aa4238, 0xc000934400}, {0x0, 0x0, 0x0})
	/tmp/build/6b18b934/code/cmd/root.go:326 +0x590
github.com/cycloidio/terracognita/cmd.glob..func13(0x1d6a10a0, {0xc0005922d0, 0xf, 0xf})
	/tmp/build/6b18b934/code/cmd/vsphere.go:55 +0x2ac
github.com/spf13/cobra.(*Command).execute(0x1d6a10a0, {0xc0005921e0, 0xf, 0xf})
	/tmp/build/6b18b934/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0x1d6a0420)
	/tmp/build/6b18b934/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
	/tmp/build/6b18b934/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
main.main()
	/tmp/build/6b18b934/code/main.go:11 +0x25

you could check the resource and on the Provider console maybe check which are the tags or which is the format they have so it could help me fix the issue :).

I'm afraid I don't know how to do that or what is a provider console :-( if you have the time to guide me, I'd be happy to

@xescugc
Copy link
Member

xescugc commented Apr 13, 2023

I've merged the PR that should prevent this error from happening but I still don't know how why was it specifically happening this with your Tags, I'll try to reproduce it but for now on master you should not have it anymore.

I'll leave the issue open as this could potentially happen again and there is something we need to investigate :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants