Skip to content

feat(aqc): add max reclaimed resource for memory and cpu#205

Open
JustinChengLZ wants to merge 2 commits into
kubewharf:mainfrom
JustinChengLZ:dev/reclaim-resource-max
Open

feat(aqc): add max reclaimed resource for memory and cpu#205
JustinChengLZ wants to merge 2 commits into
kubewharf:mainfrom
JustinChengLZ:dev/reclaim-resource-max

Conversation

@JustinChengLZ

@JustinChengLZ JustinChengLZ commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Special notes for your reviewer:

Summary by CodeRabbit

  • New Features
    • Added new admin QoS configuration options to cap maximum reclaimed CPU ratio and reclaimed memory headroom.
    • Introduced reclaimed ratio controls constrained to values between 0 and 1.
    • Added a configurable percentage mapping to set per-consumer reclaimed-resource percentages.
  • Bug Fixes
    • Improved configuration copying to ensure newly added optional fields and maps are properly deep-copied.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3b517c31-34fc-4fc6-b666-4c9f8de7ae8e

📥 Commits

Reviewing files that changed from the base of the PR and between 819e40d and fa0e81f.

📒 Files selected for processing (3)
  • config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
  • pkg/apis/config/v1alpha1/adminqos.go
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
  • pkg/apis/config/v1alpha1/adminqos.go

📝 Walkthrough

Walkthrough

Admin QoS configuration adds optional CPU and memory reclaim ratios plus a consumer-to-resource percentage map to the API types and CRD schema. Generated deepcopy logic now copies the new pointer and map fields.

Changes

Admin QoS reclaim configuration fields

Layer / File(s) Summary
API and CRD fields
pkg/apis/config/v1alpha1/adminqos.go, config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
Adds optional CPU and memory reclaim ratios constrained to 0-1, along with a consumer-to-resource percentage mapping.
DeepCopy support
pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
Updates deepcopy logic to copy the new ratio pointers and percentage map when present.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding max reclaimed resource controls for CPU and memory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.

@JustinChengLZ
JustinChengLZ force-pushed the dev/reclaim-resource-max branch from 1039b1c to 10f1404 Compare July 3, 2026 08:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pkg/apis/config/v1alpha1/adminqos.go (2)

254-259: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Comment ordering differs from sibling fields.

Validation markers precede the description here, whereas other fields (e.g. FreeBasedRatio at Line 284) place the description first. Functionally harmless since controller-gen still produced the correct CRD description, but worth aligning for consistency.

🤖 Prompt for 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.

In `@pkg/apis/config/v1alpha1/adminqos.go` around lines 254 - 259, The comment
order for ReclaimedCPUMaxRatio is inconsistent with sibling fields like
FreeBasedRatio in AdminQOSSpec. Reorder the kubebuilder validation markers and
field description so the human-readable description comes first, followed by the
validation tags and +optional, matching the style used by the other fields in
this struct.

254-259: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

JSON tag drops the "Ratio" suffix present in the Go field name.

ReclaimedCPUMaxRatio/ReclaimedMemoryMaxRatio map to reclaimedCPUMax/reclaimedMemoryMax, while sibling fields keep full name correspondence (e.g. FreeBasedRatiofreeBasedRatio, CacheBasedRatiocacheBasedRatio). Consider aligning the JSON key naming convention for consistency, though this is a cosmetic API surface choice rather than a defect.

Also applies to: 313-318

🤖 Prompt for 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.

In `@pkg/apis/config/v1alpha1/adminqos.go` around lines 254 - 259, Align the JSON
field names for the AdminQoS ratio fields so they consistently preserve the
“Ratio” suffix like the other ratio properties. Update the ReclaimedCPUMaxRatio
and ReclaimedMemoryMaxRatio struct tags in adminqos.go to use matching JSON
keys, and verify the same naming convention is applied wherever these fields are
defined or referenced, including the duplicate declaration noted by the review.
🤖 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.

Nitpick comments:
In `@pkg/apis/config/v1alpha1/adminqos.go`:
- Around line 254-259: The comment order for ReclaimedCPUMaxRatio is
inconsistent with sibling fields like FreeBasedRatio in AdminQOSSpec. Reorder
the kubebuilder validation markers and field description so the human-readable
description comes first, followed by the validation tags and +optional, matching
the style used by the other fields in this struct.
- Around line 254-259: Align the JSON field names for the AdminQoS ratio fields
so they consistently preserve the “Ratio” suffix like the other ratio
properties. Update the ReclaimedCPUMaxRatio and ReclaimedMemoryMaxRatio struct
tags in adminqos.go to use matching JSON keys, and verify the same naming
convention is applied wherever these fields are defined or referenced, including
the duplicate declaration noted by the review.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fe4f41c9-97f9-4611-a1cd-a35fad60141c

📥 Commits

Reviewing files that changed from the base of the PR and between 1039b1c and 10f1404.

📒 Files selected for processing (3)
  • config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
  • pkg/apis/config/v1alpha1/adminqos.go
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

@JustinChengLZ
JustinChengLZ force-pushed the dev/reclaim-resource-max branch from 10f1404 to 78a7ab0 Compare July 3, 2026 08:25
@JustinChengLZ
JustinChengLZ force-pushed the dev/reclaim-resource-max branch from 78a7ab0 to 170135c Compare July 7, 2026 06:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/apis/config/v1alpha1/adminqos.go`:
- Around line 158-162: Add per-entry 0–100 validation to
ReclaimedConsumerToReclaimedResourcePercentage using the project’s established
map-value validation marker, then regenerate the CRD manifests so admission
rejects negative values and values above 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 25090732-f0aa-4eb9-a238-bc69b0cc4b03

📥 Commits

Reviewing files that changed from the base of the PR and between 170135c and 819e40d.

📒 Files selected for processing (3)
  • config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
  • pkg/apis/config/v1alpha1/adminqos.go
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

Comment thread pkg/apis/config/v1alpha1/adminqos.go Outdated
Comment on lines +158 to +162
// ReclaimedConsumerToReclaimedResourcePercentage is a configuration for reclaimed consumer to a percentage of the total
// reclaimed resource, used for both headroom and provision.
// For example, {"generic": 40, "custom-consumer-1": 60}
// +optional
ReclaimedConsumerToReclaimedResourcePercentage map[string]int `json:"reclaimedConsumerToReclaimedResourcePercentage,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Constrain consumer percentages to the valid range.

This field is documented as a percentage, but its values have no validation marker; the CRD currently accepts arbitrary integers, including negative values and values above 100. Add per-entry 0..100 validation and regenerate the CRD so invalid allocation percentages are rejected at admission.

🤖 Prompt for 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.

In `@pkg/apis/config/v1alpha1/adminqos.go` around lines 158 - 162, Add per-entry
0–100 validation to ReclaimedConsumerToReclaimedResourcePercentage using the
project’s established map-value validation marker, then regenerate the CRD
manifests so admission rejects negative values and values above 100.

@JustinChengLZ
JustinChengLZ force-pushed the dev/reclaim-resource-max branch from 819e40d to fa0e81f Compare July 22, 2026 07:49
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

Successfully merging this pull request may close these issues.

1 participant