Skip to content

refactor(controller): clean up redundant logic in vpc controller#6295

Merged
oilbeater merged 2 commits intomasterfrom
refactor/vpc
Feb 12, 2026
Merged

refactor(controller): clean up redundant logic in vpc controller#6295
oilbeater merged 2 commits intomasterfrom
refactor/vpc

Conversation

@oilbeater
Copy link
Copy Markdown
Collaborator

@oilbeater oilbeater commented Feb 11, 2026

Summary

  • remove redundant vpc update calls after batch policy/static route deletions
  • simplify static route diff function signature and callers
  • avoid duplicate/ineffective logic in vpc external and static-route cleanup paths

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 11, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 focuses on enhancing the vpc controller by removing redundant and duplicate logic. The changes aim to simplify the codebase, improve efficiency by eliminating unnecessary API calls, and clarify the handling of static routes and VPC external status updates. The overall impact is a cleaner, more maintainable, and potentially more performant controller.

Highlights

  • Redundant VPC Update Calls Removed: Eliminated unnecessary VPC update calls that occurred after batch policy and static route deletions, streamlining the controller's operation.
  • Simplified Static Route Diff Function: The diffStaticRoute function's signature and its callers have been simplified by removing an unneeded error return, as the function no longer produces errors.
  • Duplicate Logic Avoided: Addressed and removed duplicate or ineffective logic within the VPC external and static-route cleanup paths, improving code efficiency and correctness.
Changelog
  • pkg/controller/vpc.go
    • Simplified the diffStaticRoute function signature by removing the error return value and its associated error handling.
    • Removed a duplicate c.addOrUpdateSubnetQueue.Add call within the handleAddOrUpdateVpc function.
    • Refactored updateVpcExternalStatus to remove the enableExternal boolean parameter, directly using vpc.Spec.EnableExternal instead.
    • Corrected a loop variable name from nodes to node in reconcileVpcBfdLRP for better readability.
    • Removed redundant Vpc().Update calls from deletePolicyRouteFromVpc, batchDeletePolicyRouteFromVpc, and batchDeleteStaticRouteFromVpc functions.
    • Adjusted the logic in handleDeleteVpcStaticRoute to correctly identify and filter BFD ECMP routes for deletion.
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 does a great job of cleaning up redundant logic in the VPC controller, particularly around VPC update calls after deletions and simplifying function signatures. The changes make the code cleaner and easier to follow.

I've found one potential issue where a logic change might prevent subnets from being reconciled when their parent VPC is updated. I've left a detailed comment with a suggestion.

Otherwise, the refactoring and bug fixes look solid. Good work!

Comment on lines 604 to 606
if subnet.Status.IsNotReady() {
c.addOrUpdateSubnetQueue.Add(subnet.Name)
}
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.

high

This change alters the logic for enqueuing subnets for reconciliation. Previously, all subnets of an updated VPC were enqueued. Now, only subnets not in a 'Ready' state are. This could prevent necessary updates on 'Ready' subnets when their parent VPC's configuration changes (e.g., spec.namespaces), potentially leading to inconsistencies.

The original code had a redundant if block. To correctly remove the redundancy while preserving the intended logic of reconciling all affected subnets, the unconditional enqueue should be kept.

c.addOrUpdateSubnetQueue.Add(subnet.Name)

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 11, 2026

Pull Request Test Coverage Report for Build 21931247912

Details

  • 8 of 43 (18.6%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 23.011%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/controller/vpc.go 8 43 18.6%
Files with Coverage Reduction New Missed Lines %
pkg/controller/vpc.go 1 16.76%
Totals Coverage Status
Change from base Build 21899872515: 0.03%
Covered Lines: 12510
Relevant Lines: 54365

💛 - Coveralls

@oilbeater oilbeater force-pushed the refactor/vpc branch 4 times, most recently from 84c4a6b to fadcd77 Compare February 11, 2026 10:11
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
@oilbeater oilbeater merged commit 436b519 into master Feb 12, 2026
146 of 148 checks passed
@oilbeater oilbeater deleted the refactor/vpc branch February 12, 2026 03:35
oilbeater added a commit that referenced this pull request Feb 12, 2026
* chore: remove unnecessary updates

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>

* clean up vpc controller

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>

---------

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
(cherry picked from commit 436b519)
zbb88888 pushed a commit to qiniu/kube-ovn that referenced this pull request Apr 8, 2026
…eovn#6295)

* chore: remove unnecessary updates

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>

* clean up vpc controller

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>

---------

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
(cherry picked from commit 436b519)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:L This PR changes 100-499 lines, ignoring generated files. vpc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants