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 configuration options for NIC bandwidth eviction, including enablement, thresholds, ring settings, grace period, and utilization limits.
    • Added support for PID overuse eviction with pod selection filters, grace period, and threshold settings.
    • Introduced new pod sale mode annotation values for spot, scheduled, reserved, and default workloads.
  • Tests

    • Added coverage to verify the new pod sale mode annotation and value constants.

@junyu-peng junyu-peng changed the title Dev/eviction feat: add eviction plugin config Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds NIC bandwidth eviction and PID overuse eviction configuration to the AdminQoSConfiguration API (Go types, CRD schema, and deepcopy generation), and introduces new exported pod sale-mode annotation constants with an accompanying test.

Changes

NIC Bandwidth and PID Overuse Eviction Configuration

Layer / File(s) Summary
API type definitions
pkg/apis/config/v1alpha1/adminqos.go
NetworkEvictionConfig gains NIC bandwidth eviction fields (enable flag, utilization threshold, continuous/ring thresholds, ring size, grace period); new PIDOveruseEvictionConfig struct defined with enable flag, threshold, pod selectors, and grace period; EvictionConfig gains a PIDOveruseEvictionConfig field.
CRD schema updates
config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml
CRD schema updated to expose enableNICBandwidthEviction, NIC bandwidth tuning properties, and a new pidOveruseEvictionConfig block matching the API types.
Generated deepcopy support
pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
EvictionConfig.DeepCopyInto and NetworkEvictionConfig.DeepCopyInto updated for new fields; new DeepCopyInto/DeepCopy methods added for PIDOveruseEvictionConfig.

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 (PodSaleModeSpot, PodSaleModeScheduled, PodSaleModeReserved, PodSaleModeDefault), and a new test validating their string values.

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

Sequence Diagram(s)

Not applicable — changes are configuration schema/type additions and constant definitions without multi-component control flow.

Suggested labels: api-change, config, needs-generated-code-review

Suggested reviewers: kubewharf/katalyst-api maintainers familiar with eviction configuration and CRD generation

🚥 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 is concise and accurately summarizes 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 on lines +849 to +857
// NICBandwidthRingSize is the size of the bandwidth pressure ring buffer.
// +kubebuilder:validation:Minimum=1
// +optional
NICBandwidthRingSize *int64 `json:"nicBandwidthRingSize,omitempty"`

// NICBandwidthRingMetThreshold is the number of ring hits required for eviction.
// +kubebuilder:validation:Minimum=1
// +optional
NICBandwidthRingMetThreshold *int64 `json:"nicBandwidthRingMetThreshold,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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject nicBandwidthRingMetThreshold values larger than nicBandwidthRingSize.

These knobs are only validated independently right now, so a config like ringSize=3 and ringMetThreshold=5 passes schema even though the ring-hit condition can never be satisfied. Please enforce nicBandwidthRingMetThreshold <= nicBandwidthRingSize in API/admission validation.

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

Comment on lines +883 to +886
// GracePeriod is the grace period of nic health eviction
// +kubebuilder:validation:Minimum=0
// +optional
GracePeriod *int64 `json:"gracePeriod,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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the GracePeriod description for PID overuse eviction.

The comment still says "nic health eviction", and that typo is already flowing into the generated CRD text, so kubectl explain will describe this new knob incorrectly.

✏️ Proposed fix
-	// GracePeriod is the grace period of nic health eviction
+	// GracePeriod is the grace period of pid overuse eviction
📝 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
// GracePeriod is the grace period of nic health eviction
// +kubebuilder:validation:Minimum=0
// +optional
GracePeriod *int64 `json:"gracePeriod,omitempty"`
// GracePeriod is the grace period of pid overuse eviction
// +kubebuilder:validation:Minimum=0
// +optional
GracePeriod *int64 `json:"gracePeriod,omitempty"`
🤖 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 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.

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