reconciler: fix correctImages panic when pod has no containers - #3904
reconciler: fix correctImages panic when pod has no containers#3904sebrandon1 wants to merge 1 commit into
Conversation
pod.Spec.Containers[0] was accessed without a length guard in the non-ExtractContent path of correctImages, causing a panic for any pod with an empty containers slice (e.g. evicted or malformed pods). The ExtractContent path already had an equivalent guard. Add TestCorrectImages covering both paths including the empty-containers case and the ExtractContent serving-image mismatch case.
|
Hi @sebrandon1. Thanks for your PR. I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe ChangesImage validation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change prevents a panic when a pod has no containers while preserving the existing behavior for normal pods. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 golangci-lint (2.12.2)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions 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 |
|
/ok-to-test |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tmshort 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 |
Summary
correctImagesaccessedpod.Spec.Containers[0]without a length guard in the non-ExtractContentpath, causing a panic for pods with an empty containers slice (e.g. evicted or malformed pods)ExtractContentpath already had an equivalentlen(pod.Spec.Containers) != 1guard; this brings the fallback path in lineTestCorrectImagescovering both paths, including the empty-containers regression case and anExtractContentserving-image mismatch caseTest plan
go test ./pkg/controller/registry/reconciler/... -run TestCorrectImages— all 6 cases passSummary by CodeRabbit
Bug Fixes
Tests