Fallback to physical capacity in cortex capacity KPI#731
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughCollect is refactored to use a new kvmHost abstraction, deriving per-resource capacity by preferring HypervisorStatus.EffectiveCapacity and falling back to HypervisorStatus.Capacity. Allocation values default to zero when missing, PAYG results are clamped to zero, and hypervisor label construction is moved into the kvmHost helper. Changes
Sequence Diagram(s)(No sequence diagrams generated — changes are localized refactor + per-resource fallback and clamping; not required.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/knowledge/kpis/plugins/compute/resource_capacity_kvm.go`:
- Around line 186-216: The code currently continues when EffectiveCapacity is
non-nil but missing CPU or RAM entries; change the logic in the block around the
checks of hasCPUTotal/hasRAMTotal so that missing entries are treated like
zeroes and trigger the same physical-capacity fallback used later: when
!hasCPUTotal || !hasRAMTotal, log a warning, then if hypervisor.Status.Capacity
is non-nil read cpuTotal/ramTotal from hypervisor.Status.Capacity
(hv1.ResourceCPU, hv1.ResourceMemory) and only continue/skip if those physical
values are nil/zero (or both zero), otherwise proceed using the physical totals;
update the slog messages to reflect the fallback path and retain the existing
zero-capacity checks (cpuTotal.IsZero()/ramTotal.IsZero()).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9cea037b-9209-4c6b-9c46-fcc8eedf6933
📒 Files selected for processing (2)
internal/knowledge/kpis/plugins/compute/resource_capacity_kvm.gointernal/knowledge/kpis/plugins/compute/resource_capacity_kvm_test.go
Test Coverage ReportTest Coverage 📊: 70.1% |
Changes
Currently if the effective capacity of a hypervisor is not set we just skip the host. This PR introduces a fallback to the physical capacity in this case.