-
Notifications
You must be signed in to change notification settings - Fork 489
remove lsp when gw nodes change #5591
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
Conversation
Signed-off-by: Mengxin Liu <[email protected]>
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.
Summary of Changes
Hello @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 bug in the external gateway functionality where logical switch ports (LSPs) were not correctly removed when gateway nodes changed. Previously, the code attempted to delete a logical router port, which was an incorrect operation for patch ports connecting a logical router to a logical switch. The fix now correctly identifies and removes the logical patch port, improving the robustness and idempotency of external gateway operations and resolving configuration error issues.
Highlights
- External Gateway Bug Fix: Corrected the logic for removing network connections related to external gateways, specifically addressing issues when gateway nodes change.
- Logical Port Handling: Changed the method from deleting a generic logical router port (
DeleteLogicalRouterPort
) to specifically removing a logical patch port (RemoveLogicalPatchPort
), which is the correct approach for the inter-component connections. - Improved Idempotency: This change helps prevent configuration errors and improves the idempotency of external gateway operations, addressing long-standing issues with the older code.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 addresses a bug in the external gateway cleanup logic. By replacing DeleteLogicalRouterPort
with RemoveLogicalPatchPort
, it ensures that both the logical router port and its corresponding logical switch port are deleted, preventing dangling resources. This is a good improvement for the stability and correctness of the external gateway feature. I've added one suggestion to improve maintainability by refactoring the port naming logic.
klog.Infof("delete logical router port %s", lrpName) | ||
if err := c.OVNNbClient.DeleteLogicalRouterPort(lrpName); err != nil { | ||
klog.Errorf("failed to delete lrp %s, %v", lrpName, err) | ||
lspName := fmt.Sprintf("%s-%s", c.config.ExternalGatewaySwitch, c.config.ClusterRouter) |
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 logic for constructing lspName
here, and lrpName
on the previous line, is duplicated in other places like CreateGatewayLogicalSwitch
. To improve maintainability and consistency, consider creating a helper function in the util
package to centralize this naming convention.
For example, you could add a function like this to pkg/util/ovn.go
:
func GetGatewayPortNames(lrName, lsName string) (lrpName, lspName string) {
lrpName = fmt.Sprintf("%s-%s", lrName, lsName)
lspName = fmt.Sprintf("%s-%s", lsName, lrName)
return
}
And then use it here and in other places where these names are constructed.
Pull Request Test Coverage Report for Build 16904223583Details
💛 - Coveralls |
Signed-off-by: Mengxin Liu <[email protected]> (cherry picked from commit 9691549)
Signed-off-by: Mengxin Liu <[email protected]> (cherry picked from commit 9691549)
Pull Request
What type of this PR
Examples of user facing changes:
The external gateway uses some very old code that contains many poorly considered aspects. For example, configuration errors can cause the entire feature to fail, and it cannot achieve operation idempotency etc.
Also I think it's not necessary to remove and then recreate ports when gw nodes change.
However, this is just a temporary quick fix to address user feedback problems.
Which issue(s) this PR fixes
Fixes #5262