Skip to content

controller: fix LSP gc when no ls key in external-ids#6103

Merged
zhangzujian merged 2 commits intokubeovn:masterfrom
zhangzujian:fix-lsp-gc
Dec 25, 2025
Merged

controller: fix LSP gc when no ls key in external-ids#6103
zhangzujian merged 2 commits intokubeovn:masterfrom
zhangzujian:fix-lsp-gc

Conversation

@zhangzujian
Copy link
Copy Markdown
Member

@zhangzujian zhangzujian commented Dec 25, 2025

Pull Request

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes

$ kubectl ko nbctl list logical_switch_port 17c45ebf-fde6-4e99-8197-e71f42bc12a9
_uuid               : 17c45ebf-fde6-4e99-8197-e71f42bc12a9
addresses           : ["00:00:00:A5:1D:68 10.103.0.92"]
dhcpv4_options      : []
dhcpv6_options      : []
dynamic_addresses   : []
enabled             : []
external_ids        : {pod="e2eproject-acp-0-ns/acp-app-import-6ql4r", vendor=kube-ovn}
ha_chassis_group    : []
mirror_rules        : []
name                : acp-app-import-6ql4r.e2eproject-acp-0-ns
options             : {}
parent_name         : []
port_security       : []
tag                 : []
tag_request         : []
type                : ""
up                  : false
$ kubectl -n kube-system logs kube-ovn-controller-7dff5b6dbb-6rjdm | grep acp-app-import-6ql4r
I1225 13:49:47.097909       7 gc.go:386] gc ip acp-app-import-6ql4r.e2eproject-acp-0-ns
I1225 13:49:47.206217       7 ip.go:236] handle deleting ip acp-app-import-6ql4r.e2eproject-acp-0-ns
I1225 13:49:47.206433       7 ip.go:250] delete ip cr lsp acp-app-import-6ql4r.e2eproject-acp-0-ns from switch ovn-default
E1225 13:49:47.207001       7 ip.go:252] failed to delete ip cr lsp acp-app-import-6ql4r.e2eproject-acp-0-ns from switch ovn-default: empty logical switch name
E1225 13:49:47.207041       7 controller.go:1442] "Unhandled Error" err="error syncing update ip \"acp-app-import-6ql4r.e2eproject-acp-0-ns\": empty logical switch name, requeuing" logger="UnhandledError"

Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
@zhangzujian zhangzujian added bug Something isn't working need backport labels Dec 25, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @zhangzujian, 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 controller's garbage collection mechanism for Logical Switch Ports (LSPs). It refines the deletion operation to gracefully handle situations where the logical switch name might be empty or invalid, thereby enhancing the stability and reliability of the garbage collection process and preventing potential runtime issues.

Highlights

  • Robustness in LSP Garbage Collection: Improved the DeleteLogicalSwitchPortOp function to prevent errors during Logical Switch Port (LSP) garbage collection when the associated logical switch name (lsName) is empty or not found, specifically addressing scenarios where no ls key exists in external-ids.

🧠 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.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 fixes a bug in the logical switch port (LSP) garbage collection that occurs when an LSP is missing the logical switch (LS) key in its external-ids. The original code would error when checking for the existence of an empty LS name. The change correctly adds a guard to only check for LS existence if the name is provided, allowing the subsequent logic to find the LS by the LSP's UUID. This is a good fix that makes the GC process more resilient. While outside the scope of this PR, a future improvement could be to make LogicalSwitchUpdatePortOp treat cases where an LSP is already detached from any LS as a no-op instead of an error to further improve robustness.

@zhangzujian zhangzujian marked this pull request as ready for review December 25, 2025 08:15
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 25, 2025
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 25, 2025
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 20501951718

Details

  • 6 of 9 (66.67%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.004%) to 22.644%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/ovs/ovn-nb-logical_switch_port.go 6 9 66.67%
Totals Coverage Status
Change from base Build 20497820799: -0.004%
Covered Lines: 12088
Relevant Lines: 53383

💛 - Coveralls

@zhangzujian zhangzujian merged commit 38025b2 into kubeovn:master Dec 25, 2025
71 of 74 checks passed
@zhangzujian zhangzujian deleted the fix-lsp-gc branch December 25, 2025 09:05
zhangzujian added a commit that referenced this pull request Dec 25, 2025
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer need backport size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants