fix: support device allocation for multi-container with init containers#1650
Conversation
Summary of ChangesHello @haitwang-cloud, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves issues related to device allocation in Kubernetes pods that utilize both init containers and regular containers. The changes ensure that device requests are correctly processed and mapped to the appropriate containers by fixing indexing logic and preventing the premature skipping of container device entries. This improves the robustness of device allocation for complex pod configurations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
ae0f945 to
904f282
Compare
There was a problem hiding this comment.
Code Review
This pull request addresses a bug in device allocation for multi-container pods that include init containers. The changes correctly handle container indexing for both init and regular containers, prevent skipping of empty device entries to maintain index integrity, and adjust the logic for identifying pending pods in multi-container scenarios. The fixes appear correct and well-targeted. I've included a couple of suggestions to improve code maintainability and readability.
|
U can reproduce the bug by the following yaml |
DSFans2014
left a comment
There was a problem hiding this comment.
please fix the failed test
|
@DSFans2014 Done,PTAL again |
a688936 to
6a6d46b
Compare
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.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
@Shouren @DSFans2014 @archlitchi PTAL, and let me know if u have any concerns |
…tainers Signed-off-by: Tim <tim.wang03@sap.com>
Remove trailing whitespace from blank lines in the Resourcereqs function to maintain consistent code style. Signed-off-by: Tim <tim.wang03@sap.com>
Update test cases to reflect actual decode behavior where trailing ";" in annotation format produces an extra empty ContainerDevices element. - Add explicit 'want' field to separate input args from expected output - Document the encode/decode roundtrip behavior in test comments - Fix assertion to compare against expected 'want' values instead of args - Add missing empty ContainerDevices to Test_DecodePodDevices expected output Signed-off-by: Tim <tim.wang03@sap.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Tim <tim.wang03@sap.com>
6a6d46b to
5f4d1d1
Compare
…t containers Signed-off-by: Tim <tim.wang03@sap.com>
Signed-off-by: Tim <tim.wang03@sap.com>
|
@Shouren PTAL again, I have address all the UT error. |
@haitwang-cloud I am attending KubeCon EU this week. I will review it next week. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: haitwang-cloud, 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 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This commit fixes the 'device request not found' error that occurs when
allocating devices to multi-container pods that contain init containers.
Problem:
allocation index mapping was incorrect
not properly handling the index offset between init containers and
regular containers
mapping
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: