fix(controller): prevent NPE in isOvnSubnet when subnet is nil#6312
fix(controller): prevent NPE in isOvnSubnet when subnet is nil#6312
Conversation
When an IP CR references a deleted subnet, handleUpdateIP calls isOvnSubnet with a nil subnet pointer, causing a panic that puts the controller into CrashLoopBackOff. Add a nil check so that isOvnSubnet safely returns false for nil input. Fixes #6309 Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Summary of ChangesHello @oilbeater, 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 addresses a critical bug that caused a nil pointer dereference in the controller when an IP resource was associated with a subnet that no longer existed. The changes ensure that the controller can robustly handle such edge cases, preventing crashes and maintaining stability by gracefully skipping operations on deleted resources. This significantly improves the controller's resilience and error handling. Highlights
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
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a nil pointer dereference in isOvnSubnet by adding a necessary nil check. This fix prevents the controller from panicking when handling IP resources that reference a deleted subnet. The changes are well-supported by the addition of a new unit test for isOvnSubnet and a valuable integration test for handleUpdateIP, ensuring the fix is robust and preventing future regressions. The test infrastructure has been appropriately updated to accommodate these new tests. The code quality is high, and the changes are clear and correct.
When an IP CR references a deleted subnet, handleUpdateIP calls isOvnSubnet with a nil subnet pointer, causing a panic that puts the controller into CrashLoopBackOff. Add a nil check so that isOvnSubnet safely returns false for nil input. Fixes #6309 Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 3a28ee1)
…vn#6312) When an IP CR references a deleted subnet, handleUpdateIP calls isOvnSubnet with a nil subnet pointer, causing a panic that puts the controller into CrashLoopBackOff. Add a nil check so that isOvnSubnet safely returns false for nil input. Fixes kubeovn#6309 Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 3a28ee1) (cherry picked from commit be347ca)
Summary
isOvnSubnet()when called with a nil subnet (regression from controller: fix stale ip cr after subnet deletion #6275)handleUpdateIPnow safely skips OVN port cleanup instead of panickingisOvnSubnet(nil/empty/OVN/non-OVN provider) and integration test forhandleUpdateIPwith a deleted subnetFixes #6309
Test plan
make lintpasses (0 issues)Test_isOvnSubnet— nil subnet returns false without panicTest_handleUpdateIP_deletedSubnet— IP referencing deleted subnet is handled gracefully🤖 Generated with Claude Code