Skip to content

ECOPROJECT-4630 | feat: Add cluster utilization to inventory schema#1196

Merged
openshift-merge-bot[bot] merged 1 commit into
kubev2v:mainfrom
ronenav:4630-sizer-used-resources
May 26, 2026
Merged

ECOPROJECT-4630 | feat: Add cluster utilization to inventory schema#1196
openshift-merge-bot[bot] merged 1 commit into
kubev2v:mainfrom
ronenav:4630-sizer-used-resources

Conversation

@ronenav
Copy link
Copy Markdown
Collaborator

@ronenav ronenav commented May 26, 2026

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

  • New Features
    • Cluster utilization metrics now available with CPU and memory statistics (average, p95, and maximum values).
    • Added confidence field for utilization data accuracy assessment.

Review Change Stack

@ronenav ronenav requested a review from a team as a code owner May 26, 2026 06:55
@ronenav ronenav requested review from AvielSegev and amalimov and removed request for a team May 26, 2026 06:55
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Warning

Review limit reached

@ronenav, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8c58457c-f3e8-4a56-9403-9e466d21834e

📥 Commits

Reviewing files that changed from the base of the PR and between 3f1ce03 and 0d187fb.

📒 Files selected for processing (7)
  • api/v1alpha1/agent/spec.gen.go
  • api/v1alpha1/openapi.yaml
  • api/v1alpha1/spec.gen.go
  • api/v1alpha1/types.gen.go
  • pkg/inventory/converters/to_api.go
  • pkg/inventory/converters/to_api_test.go
  • pkg/inventory/model.go
📝 Walkthrough

Walkthrough

This PR adds cluster-level CPU and memory utilization metrics to the inventory system. A new ClusterUtilization domain model tracks average, p95, and maximum utilization percentages plus a confidence score, flows through the API contract as an optional field on InventoryData, and includes conversion logic with test coverage.

Changes

Cluster Utilization Feature

Layer / File(s) Summary
Domain model definition
pkg/inventory/model.go
ClusterUtilization struct added with CPU/memory utilization metrics (avg/p95/max) and confidence; InventoryData extended to include optional ClusterUtilization field.
API schema and generated types
api/v1alpha1/openapi.yaml, api/v1alpha1/types.gen.go, api/v1alpha1/spec.gen.go, api/v1alpha1/agent/spec.gen.go
OpenAPI ClusterUtilization schema defined with validation bounds (0–100), InventoryData schema extended with clusterUtilization property, and generated Go types and embedded Swagger specifications updated to reflect new structure.
Domain-to-API conversion and tests
pkg/inventory/converters/to_api.go, pkg/inventory/converters/to_api_test.go
toAPIInventoryData conditionally maps domain ClusterUtilization to API model; new TestToAPI_ClusterUtilization validates conversion when data is present, nil behavior when absent, and per-cluster correctness.

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly Related PRs

  • kubev2v/migration-planner#1171: Both PRs extend InventoryData with new cluster-level fields and modify the inventory conversion flow; this PR adds utilization metrics while the related one adds DRS cluster features.

Suggested Labels

lgtm, approved, ok-to-test

Suggested Reviewers

  • AvielSegev
  • nirarg

Poem

🐰 Metrics hop through the domain,
Skip to schemas, dance through types,
Conversion flows, tests align—
Utilization now in sight! 📊✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add cluster utilization to inventory schema' accurately and clearly summarizes the main change across all files in the PR, which consistently adds ClusterUtilization support to the inventory schema.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Signed-off-by: Ronen Avraham <ravraham@redhat.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d735636 and 3f1ce03.

📒 Files selected for processing (7)
  • api/v1alpha1/agent/spec.gen.go
  • api/v1alpha1/openapi.yaml
  • api/v1alpha1/spec.gen.go
  • api/v1alpha1/types.gen.go
  • pkg/inventory/converters/to_api.go
  • pkg/inventory/converters/to_api_test.go
  • pkg/inventory/model.go

Comment thread pkg/inventory/converters/to_api_test.go
Comment thread pkg/inventory/converters/to_api.go
@ronenav ronenav force-pushed the 4630-sizer-used-resources branch from 3f1ce03 to 0d187fb Compare May 26, 2026 06:58
@AvielSegev
Copy link
Copy Markdown
Collaborator

/approve

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 26, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Jos-Jerus
Copy link
Copy Markdown
Collaborator

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label May 26, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit a0b90cb into kubev2v:main May 26, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants