fix(ascend): reject over-capacity memory on requests-only pods - #2541
fix(ascend): reject over-capacity memory on requests-only pods#2541VedantMadane wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: VedantMadane 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 |
|
Welcome @VedantMadane! 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)
📝 WalkthroughWalkthroughAscend resource handling now falls back from limits to requests, initializes resource maps, preserves oversized memory requests, and validates requests-only memory allocations. Regression tests cover request generation and admission behavior. ChangesAscend resource validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/device/ascend/device.go`:
- Around line 119-124: Initialize ctr.Resources.Limits and
ctr.Resources.Requests immediately after the resource count fallback and before
the Ascend910C SuperPod mutation branch, so requests-only containers can be
updated without a nil-map panic. Preserve the existing count lookup and mutation
behavior, and add a regression test covering an Ascend910C SuperPod container
with only a one-device request.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7ba64a23-7cf9-451a-accf-431393633e0d
📒 Files selected for processing (2)
pkg/device/ascend/device.gopkg/device/ascend/device_test.go
MutateAdmission only read device count and memory from limits so requests-only pods skipped validation. GenerateResourceRequests treated trimMemory(0) as unspecified and defaulted to 100% of a card. Fall back to requests in MutateAdmission and only apply the whole-card memory default when memory was not requested at all. Signed-off-by: Vedant Madane <vedantnm@gmail.com>
0b96931 to
86c494e
Compare
Requests-only pods can hit the SuperPod reqNum==1 path which writes Limits. Initialize Requests and Limits before that branch to avoid a nil-map panic. Add regression test. Signed-off-by: Vedant Madane <vedantnm@gmail.com>
|
You can view the relevant rule here. |
Description of the change
Ascend admission rejected over-capacity memory under limits but not under requests only. MutateAdmission returned early when the device count was missing from limits so the memory check never ran. GenerateResourceRequests fell back to requests and called trimMemory but treated a zero result (over capacity) as "no memory requested" and set MemPercentagereq to 100.
This change:
Benefits
Possible drawbacks
Applicable issues
Additional information
go test ./pkg/device/ascend -run GenerateResourceRequests/MutateAdmission_RequestsOnly passes locally.
Summary by CodeRabbit
Bug Fixes
Tests