Skip to content

feat: add eviction plugin config - #203

Open
junyu-peng wants to merge 1 commit into
kubewharf:mainfrom
junyu-peng:dev/eviction
Open

feat: add eviction plugin config#203
junyu-peng wants to merge 1 commit into
kubewharf:mainfrom
junyu-peng:dev/eviction

Conversation

@junyu-peng

@junyu-peng junyu-peng commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

Features

What this PR does / why we need it:

  1. add pid overuse and network bandwidth config
  2. add pod sale mode annotation

Which issue(s) this PR fixes:

Special notes for your reviewer:

Summary by CodeRabbit

  • New Features
    • Added new Admin QoS eviction settings for NIC bandwidth-based eviction (enablement, utilization thresholds, consecutive met thresholds, ring sizing, and grace period).
    • Added pod-level PID overuse eviction configuration, including enablement, candidate pod selection, grace period, and PID overuse threshold.
    • Introduced pod sale mode annotation values for spot, scheduled, reserved, and default workloads.
  • Tests
    • Added tests validating the new pod sale mode annotation and constant values.

@junyu-peng junyu-peng changed the title Dev/eviction feat: add eviction plugin config Jun 30, 2026
@junyu-peng
junyu-peng force-pushed the dev/eviction branch 2 times, most recently from 3005843 to 61a746d Compare July 1, 2026 08:59
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fb3846db-ea56-49f6-ae0c-68a91882c2a9

📥 Commits

Reviewing files that changed from the base of the PR and between 61a746d and 71cca37.

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

📝 Walkthrough

Walkthrough

Adds NIC bandwidth eviction and PID overuse eviction configuration to the AdminQoSConfiguration API, and introduces exported pod sale-mode annotation constants with a test.

Changes

NIC Bandwidth and PID Overuse Eviction Configuration

Layer / File(s) Summary
API type definitions for new eviction fields
pkg/apis/config/v1alpha1/adminqos.go
NetworkEvictionConfig gains NIC bandwidth eviction fields; PIDOveruseEvictionConfig is added; EvictionConfig gains a PIDOveruseEvictionConfig pointer.
CRD schema updates for new eviction fields
config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
CRD schema updated to expose enableNICBandwidthEviction, NIC bandwidth tuning properties, and the pidOveruseEvictionConfig block.
Generated deepcopy support for new fields
pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
EvictionConfig.DeepCopyInto and NetworkEvictionConfig.DeepCopyInto handle the new fields, and PIDOveruseEvictionConfig gets DeepCopyInto/DeepCopy methods.

Pod Sale Mode Constants

Layer / File(s) Summary
Sale mode constants and test
pkg/consts/pod.go, pkg/consts/pod_test.go
Adds PodAnnotationSaleModeKey and sale-mode value constants, plus a test that checks their string values.

Estimated code review effort: 2 (Simple) | ~12 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 eviction plugin configuration support.
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

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: 2

🧹 Nitpick comments (1)
pkg/consts/pod.go (1)

45-53: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Doc comment only covers one of five exported constants.

The comment above the block describes only PodAnnotationSaleModeKey, but the block also exports four PodSaleMode* value constants without their own documentation.

✏️ Suggested doc comment tweak
-// PodAnnotationSaleModeKey is a const variable for pod annotation about pod sale mode.
+// PodAnnotationSaleModeKey is the pod annotation key for pod sale mode, and
+// PodSaleMode* are the supported sale mode values.
 const (
 	PodAnnotationSaleModeKey = "katalyst.kubewharf.io/sale_mode"
🤖 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/consts/pod.go` around lines 45 - 53, The const block in
PodAnnotationSaleModeKey also exports PodSaleModeSpot, PodSaleModeScheduled,
PodSaleModeReserved, and PodSaleModeDefault, but only the first constant is
documented. Update the documentation near the const group in pod.go so each
exported symbol is covered, either by adding a block comment that describes the
sale mode values or by splitting the constants into separately documented
declarations.
🤖 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 849-857: The AdminQoS validation for NIC bandwidth ring settings
only enforces independent minimums, so `NICBandwidthRingMetThreshold` can exceed
`NICBandwidthRingSize` and still pass. Update the validation for the `AdminQoS`
API fields in `adminqos.go` to compare these two knobs and reject any spec where
`nicBandwidthRingMetThreshold` is greater than `nicBandwidthRingSize`, using the
existing `NICBandwidthRingSize` and `NICBandwidthRingMetThreshold` symbols as
the anchor for the check.
- Around line 883-886: Update the field comment on GracePeriod in adminqos.go so
the generated CRD description matches PID overuse eviction instead of nic health
eviction. Keep the kubebuilder validation/tag and the GracePeriod symbol
unchanged, and only revise the doc comment text above GracePeriod *int64 to
describe the correct eviction behavior so kubectl explain reflects the right
knob.

---

Nitpick comments:
In `@pkg/consts/pod.go`:
- Around line 45-53: The const block in PodAnnotationSaleModeKey also exports
PodSaleModeSpot, PodSaleModeScheduled, PodSaleModeReserved, and
PodSaleModeDefault, but only the first constant is documented. Update the
documentation near the const group in pod.go so each exported symbol is covered,
either by adding a block comment that describes the sale mode values or by
splitting the constants into separately documented declarations.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4520941d-bfdb-4be4-8290-033bf1b78aa3

📥 Commits

Reviewing files that changed from the base of the PR and between 7e8ae13 and 61a746d.

📒 Files selected for processing (5)
  • config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
  • pkg/apis/config/v1alpha1/adminqos.go
  • pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
  • pkg/consts/pod.go
  • pkg/consts/pod_test.go

Comment thread pkg/apis/config/v1alpha1/adminqos.go
Comment thread pkg/apis/config/v1alpha1/adminqos.go Outdated
@junyu-peng junyu-peng added the workflow/need-review review: test succeeded, need to review label Jul 7, 2026
@junyu-peng junyu-peng removed the workflow/need-review review: test succeeded, need to review label Aug 20, 2026
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