GetVirtualMachinesMetricID method throwing panic error when accessing VMs from reponse
- 主要语言
- Go
- 星标
- 39
- 派生
- 47
- PR 合并指标
- 30 天内没有已合并 PR
描述
**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](https://github.com/kubernetes-sigs/cluster-api-provider-cloudstack/blob/7b87895be9aa7d9dca1e2f70892feafd33ca4e59/pkg/cloud/instance.go#L61)
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
贡献指南
这个仓库没有索引到贡献指南
调研方向
检查 CAPC 的 cloudstack/VirtualMachineService.go 第 5543 行,以及 pkg/cloud/instance.go 第 61 行的调用方。重现 count 为 1 但 VirtualMachinesMetrics 为 nil 或为空的响应,然后确定预期的处理方式,使该方法不再 panic,并通过文档或回归测试覆盖该响应行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100