ECOPROJECT-4630 | feat: Add cluster utilization to inventory schema#1196
Conversation
|
Warning Review limit reached
More reviews will be available in 56 minutes and 13 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR adds cluster-level CPU and memory utilization metrics to the inventory system. A new ChangesCluster Utilization Feature
🎯 2 (Simple) | ⏱️ ~8 minutes Possibly Related PRs
Suggested Labels
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 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 |
Signed-off-by: Ronen Avraham <ravraham@redhat.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/inventory/converters/to_api_test.go`:
- Around line 812-897: Add boundary tests inside TestToAPI_ClusterUtilization
that verify percent fields are handled at 0 and 100 and that out-of-range values
are normalized to the 0..100 range by ToAPI: add subtests that create
domainInv.ClusterUtilization with fields (CpuAvg, CpuP95, CpuMax, MemAvg,
MemP95, MemMax, Confidence) set exactly to 0 and to 100 and assert
apiInv.Clusters["cluster-1"].ClusterUtilization preserves those exact values;
add another subtest with out-of-range inputs (e.g., -5 and 150) and assert ToAPI
normalizes/clamps them to 0 and 100 respectively so the API contract is locked
in tests.
In `@pkg/inventory/converters/to_api.go`:
- Around line 64-75: The ClusterUtilization fields are mapped without bounds
checking, which can emit values outside the API's required 0–100 range; update
the conversion in to_api.go (the block that constructs api.ClusterUtilization
and assigns result.ClusterUtilization) to validate/sanitize each field (CpuAvg,
CpuP95, CpuMax, MemAvg, MemP95, MemMax, Confidence) before assignment—either
clamp each value to the 0–100 range or return an error/reject the upstream
payload; implement this via a small helper (e.g., clampPercent(value) or
sanitizeClusterUtilization(d.ClusterUtilization)) and use that helper when
building api.ClusterUtilization so result.ClusterUtilization always contains
values within 0–100.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: dbb38e0e-c9a5-4dc6-98a8-38e53086d04c
📒 Files selected for processing (7)
api/v1alpha1/agent/spec.gen.goapi/v1alpha1/openapi.yamlapi/v1alpha1/spec.gen.goapi/v1alpha1/types.gen.gopkg/inventory/converters/to_api.gopkg/inventory/converters/to_api_test.gopkg/inventory/model.go
3f1ce03 to
0d187fb
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AvielSegev The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
Add ClusterUtilization to inventory containing CPU/memory usage percentages (avg/p95/max) and confidence metrics from rightsizing data collection.
Enables cluster sizing calculations based on actual resource consumption instead of allocated resources.
Summary by CodeRabbit