fix(server): allow disabling periodic idle vNPU cleanup to avoid premature reclamation#120
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dartagnanli The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe CLI adds a flag for periodic idle vNPU cleanup. ChangesServer cleanup lifecycle
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant PluginServer
participant Cleanup
participant GRPCServer
CLI->>PluginServer: pass cleanup flag to NewPluginServer
PluginServer->>PluginServer: Start with ps.wg.Go
PluginServer->>Cleanup: start periodic cleanup when enabled
PluginServer->>GRPCServer: start serving through ps.wg.Go
GRPCServer-->>PluginServer: stop or restart serving
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…ature reclamation The periodic idle vNPU cleanup goroutine (startPeriodicCheckIdleVNPUs) destroys vNPUs whose IsContainerUsed == 0. As discussed in Project-HAMi#86, a vNPU allocated to a Running Pod that has not yet started using the NPU also reports IsContainerUsed == 0, so the cleanup can reclaim it too early and break workloads (e.g. npu-smi info fails inside the container). Add the --enable_periodic_idle_vnpu_cleanup flag (default false) so operators can disable the periodic cleanup goroutine while the stricter policy is being revisited. The one-shot cleanup on plugin restart (cmd/main.go) is intentionally left unconditional and unchanged. Also apply Go modernizations in the touched files: interface{} -> any, wg.Add(1)+go -> wg.Go, range over int, slices.Backward. Refs Project-HAMi#86
34bc10b to
0243445
Compare
|
Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits. 📝 Please follow instructions in the contributing guide to update your commits with the DCO Full details of the Developer Certificate of Origin can be found at developercertificate.org. The list of commits missing DCO signoff:
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What & Why
Issue #86 reports that the periodic idle vNPU cleanup goroutine (
startPeriodicCheckIdleVNPUs) destroys vNPUs based solely onIsContainerUsed == 0. Because a vNPU allocated to a Pod that is alreadyRunningbut whose container has not yet started using the NPU also reportsIsContainerUsed == 0, the cleanup can reclaim the vNPU too early — breaking workloads (e.g.npu-smi infofails inside the container shortly after the Pod starts).#86 is framed as a discussion and lists several more thorough directions (combining
IsContainerUsedwith Pod allocation state, adding a protection window, or a Pod-referenced rule likemind-cluster'sDestroyNotUsedVNPU). Those require deeper changes to the cleanup policy.This PR takes a smaller, complementary step: give operators a switch to disable the periodic cleanup goroutine so the premature-reclamation symptom stops on affected nodes without waiting for the larger redesign.
Changes
--enable_periodic_idle_vnpu_cleanup(defaultfalse). Whenfalse,Start()does not launch the periodicstartPeriodicCheckIdleVNPUsgoroutine.CleanupIdleVNPUs()on plugin restart (cmd/main.go) is intentionally left unconditional and unchanged — it is a separate entry point. The flag name (enable_periodic_...) and its help text make this boundary explicit to avoid the "total cleanup switch" ambiguity.NewPluginServer.Scope note
This is a mitigation, not a full resolution of #86's cleanup-policy discussion. The flag defaults to
false(periodic cleanup disabled) to stop the premature-reclamation symptom by default; setting it totruerestores the previous behavior. Reviewers may prefer a different default — easy to adjust.Testing
go build ./internal/server/... ./cmd/...✅go vet ./internal/server/... ./cmd/...✅go test ./internal/server/— 109 passed, consistent with baseline (ran 3×)Modernizations (in the touched files)
While editing these files I also applied the Go modernization lints the editor flagged. All behavior-preserving; happy to split into a separate PR if preferred:
interface{}→anywg.Add(1)+go func(){ defer Done() }→wg.Go(...)for i := 0; i < n; i++→for i := range nslices.BackwardRefs #86
Summary by CodeRabbit
New Features
Bug Fixes
Tests