-
Notifications
You must be signed in to change notification settings - Fork 494
vpc controller: only manage static routes with kube-ovn as vendor #5838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
vpc controller: only manage static routes with kube-ovn as vendor #5838
Conversation
Summary of ChangesHello @isabelleatkins, 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 enhances the VPC controller's static route management by introducing vendor-specific filtering. The controller will now only reconcile static routes that are explicitly tagged as being managed by Kube-OVN, preventing accidental deletion or modification of static routes that may have been manually configured in OVN by users. This change improves the robustness and predictability of network configurations within Kube-OVN. Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a valuable feature to prevent the VPC controller from managing static routes it doesn't own by using a 'vendor' tag. This is a great step towards better interoperability with manual OVN configurations.
However, my review found a critical issue in the implementation. While the code now filters for the vendor tag when listing existing routes, it fails to add this tag when creating new static routes within the main reconciliation loop. This will lead to an infinite loop of route additions. Additionally, the new tests are validating this incorrect behavior.
I've left detailed comments on the affected parts of the code with suggestions for fixes. Addressing these issues is crucial for the feature to work as intended.
cd9c3b2 to
da7e6e9
Compare
Pull Request Test Coverage Report for Build 18936482776Details
💛 - Coveralls |
7ca2e4b to
e0ed97e
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly modifies the VPC controller to only manage static routes with the kube-ovn vendor, preventing accidental deletion of user-defined routes. The changes are logical and well-implemented by filtering routes based on external_ids and adding the vendor ID to newly created routes. I've added a couple of comments: one suggesting a minor refactoring to reduce code duplication, and another pointing out a missing test case to fully validate the new behavior.
| "github.com/kubeovn/kube-ovn/pkg/util" | ||
| ) | ||
|
|
||
| func Test_handleAddOrUpdateVpc_staticRoutes(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test suite is missing a key scenario to validate the main goal of this PR. You should add a test case to ensure that static routes without the kube-ovn vendor are ignored and not deleted by the controller.
This would involve:
- Creating a static route in OVN with
ExternalIDsthat are eithernilor do not contain thevendor: kube-ovnkey-value pair. - Asserting that
mockOvnClient.EXPECT().DeleteLogicalRouterStaticRoute(...)is not called for this route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is implicitly tested - if there was an additional call to DeleteLogicalRouterStaticRoute, the test would fail. In addition - we check that the ListLogicalRouterStaticRoute is called with the externalIDs filter.
| } | ||
|
|
||
| func (c *Controller) addStaticRouteToVpc(name string, route *kubeovnv1.StaticRoute) error { | ||
| externalIDs := map[string]string{"vendor": util.CniTypeName} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and reduce code duplication, consider defining externalIDs as a package-level variable. This map is also defined in handleAddOrUpdateVpc (line 342) and in the new test file pkg/controller/vpc_test.go.
You could define it once at the top of the file and reuse it:
var kubeovnExternalIDs = map[string]string{"vendor": util.CniTypeName}Then, you can use kubeovnExternalIDs in both addStaticRouteToVpc and handleAddOrUpdateVpc, as well as in the tests.
|
There's a conflict because the latest commit also changed controller_test.go. And I think we need to figure out how to add this annotation to existing route rules when upgrading from an older version. |
Signed-off-by: isabelleatkins <[email protected]>
…ations Signed-off-by: isabelleatkins <[email protected]>
e0ed97e to
7993e35
Compare

Pull Request
What type of this PR
This PR adds a small feature: