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

GetVirtualMachinesMetricID method throwing panic error when accessing VMs from reponse #103

Open
rajeshvenkata opened this issue Feb 26, 2025 · 2 comments

Comments

@rajeshvenkata
Copy link

rajeshvenkata commented Feb 26, 2025

Problem: VirtualMachineService.GetVirtualMachinesMetricID method throws panic when it is trying to access the VMs response from server in below line of code. This happens when the count in the response is 1 but the actual VirtualMachinesMetrics array in the reponse is nil or empty. This is causing panic in the caller CAPC

panic error is happening at: https://github.com/apache/cloudstack-go/blob/main/cloudstack/VirtualMachineService.go#L5543

error: panic: runtime error: index out of range [0] with length 0

version of cloudstack-go used: 2.16.1

Please help investigate this error and let us know if this response is not expected

@Pearl1594
Copy link
Contributor

@rajeshvenkata Can you please post the response of list virtualmachinesmetrics name=<name_of_the_vm> using Cloudmonkey - the CLI. Because, it is quite odd that count is 1, but it fails to retrieve the VM id.

@rajeshvenkata
Copy link
Author

@Pearl1594 Thanks for looking into this. Sure, I will try to get the response from the customer. In the meanwhile, should the code also be checking if array is nil or empty before accessing the VM array in the response? Or do you think this should not happen ideally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants