fix(ascend): do not overwrite ASCEND_VISIBLE_DEVICES for Ascend containers - #2953
fix(ascend): do not overwrite ASCEND_VISIBLE_DEVICES for Ascend containers#2953peachest wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: peachest 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe Ascend device configuration now records all resource names. Admission mutation detects Ascend resource requests and evaluates the last environment-variable entry. Regression tests cover overwrite behavior for Ascend and non-Ascend containers. ChangesAscend overwrite-env behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Ascend-requesting containers retain the device plugin's assigned visibility value, while non-Ascend containers continue to receive a single empty visibility value. No current merge-blocking risk remains. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes address issue ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
440ded9 to
80fa1ca
Compare
|
hi @peachest , I noticed that HAMi/charts/hami/templates/scheduler/device-configmap.yaml Lines 114 to 127 in f47cd28 |
I think this is a good idea. At the time of #1738, there is no global config for all ascend chips so I put these two fields under each ascend chip. There is another pr #2966 to enable more granular control over the behavior of overwriting env I am wondering is there a better method to do this only once instead of multiple times in each chips for each container in the Lines 97 to 104 in 9e75c87 |
…iners Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
80fa1ca to
1180a25
Compare
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
What type of PR is this?
/kind bug
What this PR does / why we need it:
Fixes a bug in the ascend
overwriteEnvinjection (introduced in #1738):when multiple Ascend chip types are registered, a container that requests one of them still gets
ASCEND_VISIBLE_DEVICESclobbered by empty values injected by the other chip instances, so ascend-docker-runtime mounts no device at all.Which issue(s) this PR fixes:
Fixes #2954
Special notes for your reviewer:
Each registered Ascend chip type has its own
Deviceinstance, and the scheduler webhook callsMutateAdmissiononce per instance. #1738 modeled the injection on the nvidia implementation, which has a single instance, so the per-instance aspect was missed: for a container that requests one chip, the other N-1 instances each take the!okbranch and each append an emptyASCEND_VISIBLE_DEVICEStocontainer.Env.Why that breaks mounting, based on #1738 and re-validation on a real Ascend
cluster — when Kubernetes starts a container, env entries are appended to
Config.Envin this order:pod.spec.containers[].env.ascend-docker-runtime then interprets them as follows:
ASCEND_VISIBLE_DEVICES: parsed from the end backwards — a later value overrides an earlier one;ASCEND_VNPU_SPECS): parsed from the beginning — values defined in the image win.So the extra empty
ASCEND_VISIBLE_DEVICESentries from the other Ascend instances override the device plugin's real value: the pod still schedules, but ascend-docker-runtime does not actually mount the Ascend devices.The fix (two guards in the
!okbranch):ASCEND_VISIBLE_DEVICESentry already equals the value we would inject, so even a multi-instance loop appends at most one entry.Containers that request no Ascend resource still get exactly one empty
ASCEND_VISIBLE_DEVICES— that is the intendedoverwriteEnvbehavior, unchanged by this PR.Hardware validation:
overwriteEnv: true.huawei.com/Ascend910B4: 1+Ascend910B4-memory: 8192(vNPU slicevir05_1c_8g) schedules and runs, pod spec carries 6 emptyASCEND_VISIBLE_DEVICESentries, container env showsASCEND_VNPU_SPECS=vir05_1c_8gbut emptyASCEND_VISIBLE_DEVICES, and no/dev/davinci*is mounted.ASCEND_VISIBLE_DEVICES=<phyid>(single value, no duplicates),ASCEND_VNPU_SPECS=vir05_1c_8g, and the assigned/dev/davinci*is mounted.Does this PR introduce a user-facing change?:
Yes — with multiple Ascend chip types registered and
overwriteEnv: true, containers that request an Ascend resource now correctly keep the device plugin'sASCEND_VISIBLE_DEVICESvalue and get their devices mounted.AI assistance disclosure: this fix was developed with AI assistance for code editing and this description's English wording. The root-cause analysis, reproduction, and hardware validation on a real 910B cluster are my own work.
Summary by CodeRabbit
ASCEND_VISIBLE_DEVICESvalues from being injected when a container requests Ascend resources.