← Back to Pull requests

fix(server): keep serving when one chip refuses device-share #137

Closed
unknown closed this pull request without merging on Oct 30, 2026 11:08 UTC
View on GitHub
unknown unknown commented on Sep 14, 2026 08:05 UTC
Author

What type of PR is this?

/kind bug

What this PR does / why we need it:

On a hami-vnpu-core node the plugin enables device-share on every chip during Start(). npu-smi set -t device-share ... -d 1 refuses to switch a chip that still runs a workload, applyDeviceShare stops at the first failure, and Start() aborts — so kubelet crash-loops the DaemonSet and the node stops advertising every huawei.com/Ascend* resource. One busy chip, whose block clears on its own once its workload finishes, takes the whole node offline (#131).

enableNodeDeviceShare now drives the chips one at a time, asking the driver whether a workload is running on each through a new Manager.IsDeviceInUse(logicID) backed by devmanager.GetDevProcessInfo, rather than interpreting npu-smi's exit code. A chip in use is logged once and queued in pendingDeviceShare; the rest are switched and stay available, including when every chip is busy. Because a workload can start between the check and the set, a refused set is followed by a second look at the process list; if the list itself cannot be read, the set is attempted and its own result decides. watchAndRegister calls retryPendingDeviceShare on every tick, so a chip is switched as soon as its workload finishes, and still-busy chips log at V(3) to avoid a warning per chip every 30 s.

As requested in review, a queued chip is not registered while it waits: it is still laid out as a whole chip, so advertising it would let the scheduler place sliced workloads on a chip that cannot slice. It is withheld from the kubelet ListAndWatch response and from the HAMi node annotation, and appears in the next tick once the switch succeeds. Index in the annotation stays continuous over the devices actually reported while NetworkID keeps following the chip's physical position, so a withheld chip in the middle of the list does not shift the network ID of the ones after it.

Any other npu-smi failure still aborts startup exactly as before. Because npu-smi is now invoked from the periodic loop too, runNpuSmi runs it under a timeout so a hung binary cannot stall watchAndRegister and with it the kubelet updates and the HAMi registration.

Which issue(s) this PR fixes:
Fixes #131

Special notes for your reviewer:

This follows the behaviour suggested in the issue discussion: skip the busy chip, keep the rest available, retry later. The busy check uses the driver's process list as requested in review rather than npu-smi's exit code; the set's own refusal is still handled for the window between the check and the set.

Unit tests in internal/server/device_share_test.go use the existing fake runNpuSmi hook and a fake IsDeviceInUse, so no hardware is involved: a busy chip is skipped and queued, an all-busy node queues everything and still starts, a chip taken between check and set is queued, an idle chip failing for another reason still fails fast, an unreadable process list falls back to the set, the retry loop drops a chip once switched, and a hung npu-smi times out. Three more cover the non-registration: the withheld chip is absent from apiDevices, absent from the HAMi annotation with Index continuous and NetworkID intact, and the device fingerprint moves when a chip is withheld or restored.

I have not run this on Ascend hardware.

Yes, AI-assisted; reviewed by me.

Does this PR introduce a user-facing change?:

``release-note
The Ascend device plugin no longer exits when
npu-smi refuses to enable device-share on a chip that is in use; the chip is withheld from registration and retried periodically while the remaining chips stay available.
``

Diff: 460 lines (+345 / -115) across 5 files Reviewer: DSFans2014 Review duration: 66422m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 460 lines diff across 5 files
0.46
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.367
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #137"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 45.6% (MEDIUM) · Higher = larger blast radius
45.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 18.0% · Safe to merge
18.0%