Skip to content

feat(config): add tmo max reclaim size - #208

Merged
cheney-lin merged 1 commit into
kubewharf:mainfrom
liunxaa:dev/refactor-tmo
Jul 17, 2026
Merged

feat(config): add tmo max reclaim size#208
cheney-lin merged 1 commit into
kubewharf:mainfrom
liunxaa:dev/refactor-tmo

Conversation

@liunxaa

@liunxaa liunxaa commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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 an optional maxReclaimSize setting to control the maximum number of bytes that can be reclaimed in a single TMO cycle.
    • A value of 0 now means “unlimited”.
    • The setting is available for all supported configuration selector scopes (including Cgroup, pool name, and QoS level configurations).

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an optional maxReclaimSize TMO configuration field, deep-copy support for its pointer value, and CRD schema entries for cgroup, pool-name, and QoS-level configuration scopes.

Changes

TMO reclaim-size configuration

Layer / File(s) Summary
TMO configuration contract
pkg/apis/config/v1alpha1/tmo.go, pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
Adds optional MaxReclaimSize configuration and deep-copies its value when set.
TMO CRD schema propagation
config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml
Adds maxReclaimSize to the cgroup, pool-name, and QoS-level configuration schemas, documenting zero as unlimited.

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 and concisely describes the main change: adding a TMO max reclaim size config.
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.

@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
`@config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml`:
- Around line 113-117: Update all three CRD schema entries for maxReclaimSize to
add a minimum constraint of 0, while preserving the existing int64 type and
description. This ensures negative values are rejected at the CRD boundary and
matches the *uint64 configuration field.
🪄 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: e866f26d-941e-4368-befc-93f0b28d07de

📥 Commits

Reviewing files that changed from the base of the PR and between 2186c66 and 9fc1c6e.

📒 Files selected for processing (3)
  • config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml
  • pkg/apis/config/v1alpha1/tmo.go
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

Comment on lines +113 to +117
maxReclaimSize:
description: MaxReclaimSize limits the bytes that can
be reclaimed in one TMO cycle. Zero means unlimited.
format: int64
type: integer

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -A5 'maxReclaimSize:' \
  config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml

Repository: kubewharf/katalyst-api

Length of output: 1261


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the Go field definitions and any validation markers for maxReclaimSize.
rg -n -A4 -B4 'maxReclaimSize|MaxReclaimSize' api pkg config -g '!**/vendor/**' || true

# Show the exact CRD sections around the three occurrences.
sed -n '108,122p' config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml
printf '\n---\n'
sed -n '251,265p' config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml
printf '\n---\n'
sed -n '331,345p' config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml

Repository: kubewharf/katalyst-api

Length of output: 9087


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the generated CRD schema source and any kubebuilder validation on the field.
rg -n -A4 -B4 'MaxReclaimSize|maxReclaimSize' api pkg config -g '*.go' -g '*.yaml' || true

Repository: kubewharf/katalyst-api

Length of output: 6515


🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat > /tmp/uint64_decode_check.go <<'EOF'
package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	var v struct {
		MaxReclaimSize *uint64 `json:"maxReclaimSize"`
	}
	err := json.Unmarshal([]byte(`{"maxReclaimSize":-1}`), &v)
	if err != nil {
		fmt.Println("ERR:", err)
		return
	}
	if v.MaxReclaimSize == nil {
		fmt.Println("OK: nil")
		return
	}
	fmt.Println("OK:", *v.MaxReclaimSize)
}
EOF

go run /tmp/uint64_decode_check.go

Repository: kubewharf/katalyst-api

Length of output: 250


Reject negative maxReclaimSize values at the CRD boundary.
maxReclaimSize is a *uint64, so a negative value will fail typed decoding even though the CRD currently accepts it as int64. Add minimum: 0 to all three schema entries.

Proposed schema fix
 maxReclaimSize:
   format: int64
+  minimum: 0
   type: integer
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
maxReclaimSize:
description: MaxReclaimSize limits the bytes that can
be reclaimed in one TMO cycle. Zero means unlimited.
format: int64
type: integer
maxReclaimSize:
description: MaxReclaimSize limits the bytes that can
be reclaimed in one TMO cycle. Zero means unlimited.
format: int64
minimum: 0
type: integer
🤖 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
`@config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml`
around lines 113 - 117, Update all three CRD schema entries for maxReclaimSize
to add a minimum constraint of 0, while preserving the existing int64 type and
description. This ensures negative values are rejected at the CRD boundary and
matches the *uint64 configuration field.

@liunxaa
liunxaa force-pushed the dev/refactor-tmo branch from 9fc1c6e to 4797f56 Compare July 17, 2026 07:38
@liunxaa
liunxaa force-pushed the dev/refactor-tmo branch from 4797f56 to d053664 Compare July 17, 2026 07:53

@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/tmo.go`:
- Around line 140-143: Update the MaxReclaimSize field validation in the TMO API
type to reject quantities with a leading negative sign while continuing to allow
zero and positive values. Use the CRD validation marker pattern used by adjacent
fields so the generated CRD enforces this constraint.
🪄 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: e7aae4a1-b545-4fab-be60-448cb6329d36

📥 Commits

Reviewing files that changed from the base of the PR and between 9fc1c6e and d053664.

📒 Files selected for processing (3)
  • config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml
  • pkg/apis/config/v1alpha1/tmo.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_transparentmemoryoffloadingconfigurations.yaml
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

Comment thread pkg/apis/config/v1alpha1/tmo.go
@cheney-lin
cheney-lin merged commit a9383de into kubewharf:main Jul 17, 2026
2 checks passed
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.

3 participants