fix(ascend): guard nil Requests in MutateAdmission - #2416
Conversation
|
Welcome @keshav9926! It looks like this is your first PR to Project-HAMi/HAMi 🎉 |
|
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 skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesAscend admission mutation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
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 |
|
please sync with master to pass the CI |
A container declaring only limits (no requests block) reaches the trimmed-memory write with ctr.Resources.Requests == nil and panics (assignment to entry in nil map) in the admission webhook. Initialize the map before writing, as kunlun vdevice already does for the same write and as merged for mthreads in Project-HAMi#2254. Add Test_MutateAdmission_NilRequests covering both panicking shapes: memory limit present without a requests block, and count-only without a requests block. Signed-off-by: keshav9926 <kkakani160@gmail.com>
afc148c to
6b8752b
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Done — rebased onto current master (now based on c5e99b6). Thanks for taking a look @archlitchi! |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: keshav9926, Shouren 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 |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
What this PR does / why we need it
MutateAdmissionin the ascend backend writes the trimmed memory quantityinto
ctr.Resources.Requestsunconditionally. When a container declares onlylimits(norequestsblock),Requestsis a nil map and the write panics(
assignment to entry in nil map) inside the admission webhook.This initializes
Requestsbefore the write, mirroring the guard the kunlunbackend already uses for the identical write
(
pkg/device/kunlun/vdevice.go), and the pattern merged for mthreads in#2254. After this, no backend under
pkg/device/writes toResources.Requestsunguarded.Also adds
Test_MutateAdmission_NilRequests: two regression cases (memorylimit without a requests block; count-only without a requests block), both of
which panic on master today.
Which issue(s) this PR fixes
Fixes #2415
Special notes for your reviewer
The existing
Test_MutateAdmissionnever hits this path with nil Requests:the only case reaching the write is the only fixture that explicitly sets a
Requestsblock. The new test covers exactly the gap.AI assistance disclosure
This PR was developed with AI assistance (Claude); the bug was found by an
automated audit of unguarded map writes across
pkg/device/, and the fix andtests were human-reviewed before submission.
Summary by CodeRabbit
Bug Fixes
Tests