govmomi: [BUG] govc metric.ls panic
Describe the bug
When running govc metric.ls the command panics
To Reproduce Steps to reproduce the behavior:
- run
govc metric.lsagainst a virtual machine
Expected behavior
No panic
Affected version Multiple versions: 0.27.4, 0.28.0
Screenshots/Debug Output
➜ ~ ./govc metric.ls -debug "$vm"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xc939bf]
goroutine 1 [running]:
github.com/vmware/govmomi/performance.groupPerfCounterInfo.Less({0xc0004e8510?, {0xc000222000?, 0xc000543b68?, 0x6d000c0001ee380?}}, 0x4?, 0x3e?)
/home/runner/work/govmomi/govmomi/performance/manager.go:208 +0x5f
sort.medianOfThree({0x13cae28, 0xc00053e700}, 0x203000?, 0x203000?, 0xc00053e700?)
/opt/hostedtoolcache/go/1.18.0/x64/src/sort/sort.go:89 +0x42
sort.doPivot({0x13cae28, 0xc00053e700}, 0x0, 0xb8)
/opt/hostedtoolcache/go/1.18.0/x64/src/sort/sort.go:114 +0x72
sort.quickSort({0x13cae28, 0xc00053e700}, 0xc0000d5ce8?, 0xc00053e700?, 0xc0000d5ce8?)
/opt/hostedtoolcache/go/1.18.0/x64/src/sort/sort.go:203 +0x6c
sort.Sort({0x13cae28, 0xc00053e700})
/opt/hostedtoolcache/go/1.18.0/x64/src/sort/sort.go:231 +0x53
github.com/vmware/govmomi/performance.(*Manager).AvailableMetric(0xc0001ee230, {0x13cb050, 0xc00012e000}, {{0xc00014a220?, 0x1?}, {0xc00014a243?, 0xc9a3eb?}}, 0x14)
/home/runner/work/govmomi/govmomi/performance/manager.go:253 +0x29a
github.com/vmware/govmomi/govc/metric.(*ls).Run(0xc000152560, {0x13cb050, 0xc00012e000}, 0x9?)
/home/runner/work/govmomi/govmomi/govc/metric/ls.go:178 +0x136
github.com/vmware/govmomi/govc/cli.Run({0xc00012c050, 0x3, 0x3})
/home/runner/work/govmomi/govmomi/govc/cli/command.go:165 +0x32d
main.main()
/home/runner/work/govmomi/govmomi/govc/main.go:113 +0x4f
➜ ~
Additional context
This issue started after our VMC SDDC was upgraded: SDDC Version: | 1.16v7
vCenter: Version: 7.0.3 Build: 19504857
We have been running this command in CI for 9 months without issue. https://github.com/openshift/release/pull/20598/files
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (5 by maintainers)
Commits related to this issue
- fix: avoid possible panic in govc metric commands Newer versions of vCenter may return a CounterId via QueryAvailablePerfMetric() which does not have a corresponding PerfCounterInfo entry in Performa... — committed to dougm/govmomi by dougm 4 years ago
- fix: avoid possible panic in govc metric commands Newer versions of vCenter may return a CounterId via QueryAvailablePerfMetric() which does not have a corresponding PerfCounterInfo entry in Performa... — committed to dougm/govmomi by dougm 4 years ago
- fix: avoid possible panic in govc metric commands Newer versions of vCenter may return a CounterId via QueryAvailablePerfMetric() which does not have a corresponding PerfCounterInfo entry in Performa... — committed to dougm/govmomi by dougm 4 years ago
I can reproduce this. Not seeing an issue with Go’s sort itself @yusufozturk , but what @jcpowermac is seeing. Where of the 163 available metrics for a vm, 1 of them does not have PerfCounterInfo. I can see from @jcpowermac 's logs and mine, vCenter is not returning that 1 PerfCounterInfo, which seems like a vCenter bug. But something we can workaround in govmomi for now to avoid the panic, I’ll try to put something together soon.