fix(server): allow disabling periodic idle vNPU cleanup to avoid premature reclamation #120
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 371 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.354
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #120"
general
weight: 0.35
DSFans2014
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
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added a CLI option
--enable_periodic_idle_vnpu_cleanupto enable periodic cleanup of idle vNPU resources.Cleanup remains disabled by default.
Bug Fixes
Improved server goroutine lifecycle and shutdown coordination for more reliable startup and termination.
Tests
* Updated server tests to match the new cleanup configuration and constructor signature, including restart-related scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->