feat: init-container GPU resource accounting#2116
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mayooot 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: Pro Plus Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (8)
📝 WalkthroughWalkthroughThe change adds init-container-aware GPU accounting. Usage is collapsed using max(init, summed app) semantics, released after successful init completion, preserved in pod state, and applied consistently across scoring, binding, admission mutation, and quota validation. ChangesInit-container GPU accounting
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Pod
participant Scheduler
participant PodManager
participant QuotaManager
Pod->>Scheduler: report init-container status and device usage
Scheduler->>PodManager: store collapsed effective footprint
Scheduler->>QuotaManager: add effective usage
Pod->>Scheduler: report successful init completion
Scheduler->>PodManager: shrink usage to app-only
Scheduler->>QuotaManager: replace previous usage with app-only usage
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
56a2a30 to
b01667e
Compare
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/initcontainer_test.go`:
- Around line 59-68: Update the loops in podWithInit to use the modern
range-over-int form required by the rangeint linter, while preserving the
existing container counts and append behavior for both InitContainers and
Containers.
🪄 Autofix (Beta)
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: e5e92b0a-8d3e-43ed-8531-8ca19a7b6883
📒 Files selected for processing (9)
pkg/device/initcontainer.gopkg/device/initcontainer_test.gopkg/device/initcontainer_usage_test.gopkg/device/pods.gopkg/scheduler/scheduler.gopkg/scheduler/score.gopkg/scheduler/score_test.gopkg/scheduler/webhook.gopkg/scheduler/webhook_test.go
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/scheduler/webhook.go`:
- Around line 75-104: Update the privileged-container handling in the mutate
closure and its init/application container callers so detection produces an
explicit admission denial rather than only a warning and nil result. Propagate
that denial immediately for both pod.Spec.InitContainers and
pod.Spec.Containers, while preserving existing mutation errors and normal
admission behavior for non-privileged containers.
🪄 Autofix (Beta)
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: 923852a8-9e68-4869-b248-44b13a5cea37
📒 Files selected for processing (9)
pkg/device/initcontainer.gopkg/device/initcontainer_test.gopkg/device/initcontainer_usage_test.gopkg/device/pods.gopkg/scheduler/scheduler.gopkg/scheduler/score.gopkg/scheduler/score_test.gopkg/scheduler/webhook.gopkg/scheduler/webhook_test.go
🚧 Files skipped from review as they are similar to previous changes (7)
- pkg/scheduler/webhook_test.go
- pkg/scheduler/score.go
- pkg/device/initcontainer.go
- pkg/device/initcontainer_usage_test.go
- pkg/scheduler/score_test.go
- pkg/device/pods.go
- pkg/scheduler/scheduler.go
Signed-off-by: Harry Li <harrymingh@gmail.com>
b01667e to
0762cf6
Compare
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
DSFans2014
left a comment
There was a problem hiding this comment.
hi @mayooot Thank you very much for your contribution. However, this overlaps with #1773 which @maishivamhoo123 is currently working on. And the documentation #2064 was also designed by him
|
/hold |
What type of PR is this?
What this PR does / why we need it:
Implements GPU resource accounting for init containers, following the design in
docs/develop/initContainer-design.md(#2064).Init containers run sequentially to completion before app containers start, so their
GPU usage should never be summed with app usage. The effective per-device footprint is:
effective = max( sum(app requests), max(init request) )
This is applied consistently across the three accounting paths:
webhook.go): quota check uses the effective value;MutateAdmissionnow also runs over init containers.
score.go): each init container is fit independently against a freshnode copy with an isolated allocation context; app containers accumulate on the real
node. Init allocations no longer pollute app quota/filter checks.
scheduler.go,pods.go): stores the collapsed view, and shrinksto app-only once init containers finish (one-time, with symmetric quota delta).
Context
Follow-up to my earlier attempt in #1278, which only touched the webhook and was
incomplete. This PR implements the full model per the merged design doc.
Summary by CodeRabbit
New Features
Bug Fixes
Tests