oVirt / go-ovirt-client

An easy-to-use overlay for the Go SDK.
https://pkg.go.dev/github.com/ovirt/go-ovirt-client
BSD 3-Clause "New" or "Revised" License
11 stars 20 forks source link

VM Getters panic on shutdown VMs #256

Open aravindhp opened 1 month ago

aravindhp commented 1 month ago

Describe the bug

GetVMByName(), GetVM(), ListVMs() etc panic if they run into a VM which is shutdown. Example:

{"time":"2024-10-22T16:45:45.989264166-07:00","level":"DEBUG","msg":"Testing oVirt engine connection..."}
{"time":"2024-10-22T16:45:46.560604734-07:00","level":"DEBUG","msg":"Completed testing oVirt engine connection."}
{"time":"2024-10-22T16:45:46.560632692-07:00","level":"DEBUG","msg":"Getting vm name ab-lnxdev01..."}
panic: the address must not be nil, please use Address() function instead

goroutine 19 [running]:
github.com/ovirt/go-ovirt.(*Ip).MustAddress(...)
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt@v0.0.0-20220427092237-114c47f2835c/types.go:25910
github.com/ovirt/go-ovirt-client/v3.convertSDKNicConfiguration(0x0?)
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt-client/v3@v3.2.0/vm.go:542 +0x358
github.com/ovirt/go-ovirt-client/v3.convertSDKInitialization(0x1?)
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt-client/v3@v3.2.0/vm.go:533 +0xc6
github.com/ovirt/go-ovirt-client/v3.vmInitializationConverter(0xce5f2b1500000003?, 0xc000226200)
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt-client/v3@v3.2.0/vm.go:2576 +0x18
github.com/ovirt/go-ovirt-client/v3.convertSDKVM(0xc0000ec588, {0xafd7e8, 0xc000443140})
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt-client/v3@v3.2.0/vm.go:2352 +0x1cf
github.com/ovirt/go-ovirt-client/v3.(*oVirtClient).GetVMByName.func1()
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt-client/v3@v3.2.0/vm_get_by_name.go:23 +0x1d5
github.com/ovirt/go-ovirt-client/v3.retry({0xc00030e8e0, 0x1b}, {0xaf35e0, 0xc000070140}, {0xc0002f4460, 0x6, 0x71aaecdb7bb8?}, 0xc000045bb8)
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt-client/v3@v3.2.0/retry.go:38 +0x25d
github.com/ovirt/go-ovirt-client/v3.(*oVirtClient).GetVMByName(0xc000443140, {0xa1a901, 0xb}, {0x0, 0x0, 0x0})
        /home/aravindh/go/pkg/mod/github.com/ovirt/go-ovirt-client/v3@v3.2.0/vm_get_by_name.go:10 +0x18e
<snip>

To Reproduce

  1. Call ListVMs() against an oVirt instance that has shutdown VMs

Expected behavior

The calls should return VM(s).

This is because convertSDKNicConfiguration always expects a Nic to have an address.