Skip to content

fix gabage u2o openflow#5757

Merged
changluyi merged 3 commits intomasterfrom
fix_gc_u2o_open_flow
Sep 29, 2025
Merged

fix gabage u2o openflow#5757
changluyi merged 3 commits intomasterfrom
fix_gc_u2o_open_flow

Conversation

@changluyi
Copy link
Copy Markdown
Collaborator

Pull Request

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes

Fixes #(issue-number)

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 25, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @changluyi, 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 related to "garbage" OpenFlow rules in Underlay-to-Overlay (U2O) communication within Kube-OVN. The changes enhance the robustness of pod deletion handling by ensuring critical pod data is available during the cleanup process, preventing potential issues where OpenFlow rules might not be properly removed. Additionally, the logic for adding OpenFlow rules has been made more precise to avoid redundant entries. A new E2E test has been introduced to thoroughly validate these fixes and ensure the stability of U2O OpenFlow rule management.

Highlights

  • Improved Pod Deletion Handling: Introduced a sync.Map to store pod objects during deletion, ensuring that handleDeletePod can access necessary pod information even if the pod is no longer in the lister, preventing issues with stale data and ensuring proper OpenFlow rule cleanup.
  • Refined OpenFlow Rule Management: Updated the AddOrUpdateU2OKeepSrcMac function to perform a more precise check for existing OpenFlow rules, specifically verifying the mod_dl_src action, which prevents redundant rule additions and ensures only necessary rules are applied.
  • New E2E Conformance Test: Added a comprehensive end-to-end test to validate the correct creation and deletion of keepSrcMac OpenFlow rules for U2O interconnection, covering pod lifecycle and u2oInterconnection status changes to prevent future regressions.
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.

@dosubot dosubot bot added the bug Something isn't working label Sep 25, 2025
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 effectively addresses a race condition during pod deletion that could lead to stale OpenFlow rules. The approach of caching the pod object at deletion enqueue time is robust. The change to make the OpenFlow rule existence check more specific is a good improvement, and the new end-to-end test provides excellent coverage for the fix. I have a couple of minor suggestions to further refine the code.

Comment on lines +224 to +228
if actionText, _ := action.MarshalText(); string(actionText) == expectedAction {
klog.V(3).Infof("flow already exists in bridge %s for in_port=%d, ip_src=%s, dl_src=%s, actions=mod_dl_src:%s",
bridgeName, localnetPatchPortID, podIP, chassisMac, podMac)
return nil
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error returned by action.MarshalText() is being ignored. While errors might be rare for standard OpenFlow actions, it's safer to handle them to prevent unexpected behavior. Please consider checking the error and logging it if it's not nil.

actionText, err := action.MarshalText()
if err != nil {
	klog.Warningf("failed to marshal action from flow: %v", err)
	continue
}
if string(actionText) == expectedAction {
	klog.V(3).Infof("flow already exists in bridge %s for in_port=%d, ip_src=%s, dl_src=%s, actions=mod_dl_src:%s",
		bridgeName, localnetPatchPortID, podIP, chassisMac, podMac)
	return nil
}


ginkgo.By("Verifying keepSrcMac OpenFlow rules are deleted after pod deletion")
// Wait a bit for the flow rules to be cleaned up
time.Sleep(2 * time.Second)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This time.Sleep is unnecessary. The subsequent call to checkKeepSrcMacFlow already uses framework.WaitUntil to poll for the expected state of the OpenFlow rules, making this explicit sleep redundant. Removing it will make the test slightly faster and more robust against timing variations.

@coveralls
Copy link
Copy Markdown

coveralls commented Sep 25, 2025

Pull Request Test Coverage Report for Build 18083704987

Details

  • 0 of 28 (0.0%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.004%) to 21.084%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/daemon/controller_linux.go 0 8 0.0%
pkg/daemon/controller.go 0 10 0.0%
pkg/ovs/ovs-ofctl.go 0 10 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/ovs/ovn-nb-logical_router_route.go 2 74.6%
Totals Coverage Status
Change from base Build 17994370999: -0.004%
Covered Lines: 10705
Relevant Lines: 50772

💛 - Coveralls

@changluyi changluyi requested a review from oilbeater September 28, 2025 12:31
Signed-off-by: clyi <clyi@alauda.io>
Signed-off-by: clyi <clyi@alauda.io>
Signed-off-by: clyi <clyi@alauda.io>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 29, 2025
@changluyi changluyi merged commit 772490f into master Sep 29, 2025
72 of 73 checks passed
@changluyi changluyi deleted the fix_gc_u2o_open_flow branch September 29, 2025 03:13
changluyi added a commit that referenced this pull request Sep 29, 2025
* fix delete pod not remove u2o flow

Signed-off-by: clyi <clyi@alauda.io>
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 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants