fix(ascend): honor nodeConfig.VDeviceCount in VDeviceCount()#100
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughModified ChangesVDeviceCount Override
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
VDeviceCount() always derived the per-card vDevice count from the global config (MemoryAllocatable / smallest template), ignoring the per-node override loaded into am.nodeConfig, even though the sibling method IsHamiVnpuCore() already prefers am.nodeConfig. As a result, setting vDeviceCount in the node config had no effect and each card kept advertising the global default slice count. Prefer nodeConfig.VDeviceCount when it is present and positive, mirroring IsHamiVnpuCore(); otherwise fall back to the existing global default. Add a table-driven unit test covering: no node config (global default), VDeviceCount=0 (fallback), VDeviceCount>0 (honored and tracks the value), and the no-template edge cases. The test fails on the previous code and passes with this change. Signed-off-by: wangmin <wangmin@riseunion.io>
0a3f264 to
1ffd7f9
Compare
Signed-off-by: wangmin <wangmin@riseunion.io>
304cc80 to
ef52ad3
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: archlitchi, Wangmin362 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does
VDeviceCount()always derived the per-card vDevice count from the global config (MemoryAllocatable / smallest template), ignoring the per-node override loaded intoam.nodeConfig— even though the sibling methodIsHamiVnpuCore()already prefersam.nodeConfig. As a result, settingvDeviceCountin the node config had no effect: every card kept advertising the global default slice count.This PR makes
VDeviceCount()prefernodeConfig.VDeviceCountwhen present and positive, mirroringIsHamiVnpuCore(), and otherwise falls back to the existing global default.Unit test
Added a table-driven test
TestVDeviceCountininternal/manager/manager_test.gocovering: no node config (global default),VDeviceCount=0(fallback),VDeviceCount>0(honored + tracks value), and the no-template edge cases.The test fails on the previous code and passes with this change — proving it pins the bug:
Real-hardware verification (8× Ascend 910B4)
Built this branch into an arm64 image and ran it on a real node with 8× Ascend 910B4 (driver 25.5.1, k8s v1.29.15, containerd 1.7.13). To avoid disturbing the node's existing device plugin, the test plugin used a distinct
commonWord/resourceName(huawei.com/Ascend910B4-f2test) — a fully isolated, additive registration.The
910B4config hasmemoryAllocatable=32768and smallest template8192, so the global default is32768/8192 = 4vDevices/card. Evidence, per tier — the per-cardcountcomes from the plugin's own HAMi node-register annotation, cross-checked against the kubelet-advertised resource capacity (8 cards):count(register annotation)matched node config … VDeviceCount:0[4,4,4,4,4,4,4,4]32vDeviceCount: 8matched node config … VDeviceCount:8[8,8,8,8,8,8,8,8]64vDeviceCount: 2matched node config … VDeviceCount:2[2,2,2,2,2,2,2,2]16All test resources were removed after the run.
Scope / safety of the test
The real-hardware test ran as a fully isolated, additive deployment: a separate namespace, a distinct
commonWord/resourceName(huawei.com/Ascend910B4-f2test) so it never collided with the productionhuawei.com/Ascend910B4registration or its HAMi node annotations. All test resources were removed afterward and the node was restored to its exact prior state.AI assistance disclosure (per the project's AI Assistance Notice): the underlying issue was diagnosed from my own testing on real Ascend 910B4 hardware. The one-function change and the unit test were drafted with AI assistance (Claude Code) and then reviewed, built, and verified by me on the hardware described above. I understand the change and stand behind it.
Summary by CodeRabbit
Bug Fixes
VDeviceCount()now honors a per-node vDevice override when a node configuration is present and the override is greater than zero.1as needed.Tests
VDeviceCount()across default, node-overridden, zero-value override, and missing-template scenarios.