perf: only enqueue subnet when necessary#6268
Conversation
Summary of ChangesHello @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 introduces performance optimizations by refining how subnets are processed and enqueued within the controller. It ensures that resources are not wasted on subnets that are being deleted or are already in a ready state, thereby improving the efficiency of subnet and VPC reconciliation processes. Highlights
Changelog
Activity
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.
Code Review
This pull request aims to improve performance by reducing unnecessary subnet reconciliations. However, the modification in pkg/controller/vpc.go to only enqueue non-ready subnets when a VPC is updated introduces a security risk. Subnets in a "Ready" state will skip reconciliation, leading to stale network configurations, such as outdated Load Balancer references or routing rules, potentially bypassing intended security policies. This inconsistent state handling has been identified as a medium-severity vulnerability.
| // Accelerate subnet update when vpc config is updated. | ||
| // In case VPC not set namespaces, subnet will backoff and may take long time to back to ready. | ||
| if subnet.Status.IsNotReady() { | ||
| c.addOrUpdateSubnetQueue.Add(subnet.Name) | ||
| } |
There was a problem hiding this comment.
The change to conditionally enqueue only non-ready subnets when a VPC is updated introduces a security vulnerability. VPC configuration changes (e.g., Load Balancer updates, BFD settings, or routing changes) require all associated subnets, including 'Ready' ones, to be re-reconciled. Skipping 'Ready' subnets can lead to stale security or network configurations, such as outdated Load Balancer references or incorrect routing rules, potentially bypassing intended network security policies or service exposure changes.
Remediation: To ensure configuration consistency and prevent security risks, remove the conditional check and always enqueue all subnets belonging to the VPC when it is updated.
| // Accelerate subnet update when vpc config is updated. | |
| // In case VPC not set namespaces, subnet will backoff and may take long time to back to ready. | |
| if subnet.Status.IsNotReady() { | |
| c.addOrUpdateSubnetQueue.Add(subnet.Name) | |
| } | |
| c.addOrUpdateSubnetQueue.Add(subnet.Name) |
Pull Request Test Coverage Report for Build 21808576888Details
💛 - Coveralls |
601297c to
098601c
Compare
be34c3d to
75209a5
Compare
75209a5 to
f6c95e8
Compare
4bd5453 to
b67e9f3
Compare
b9af62d to
4e98779
Compare
a1bb237 to
5bdf2f3
Compare
24fa128 to
43e1472
Compare
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
43e1472 to
eaf4e1c
Compare
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com> (cherry picked from commit 1adb28a)
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com> (cherry picked from commit 1adb28a)
…eAddOrUpdateVpc Cherry-pick of kubeovn#6268 introduced a duplicate unconditional call to addOrUpdateSubnetQueue.Add alongside the IsNotReady() conditional call, causing every subnet to be enqueued twice on VPC update. Restore correct behavior matching release-1.15: only enqueue when subnet is not ready.
Only enqueue subnet when necessary to improve performance.
Also fix vpc reconcile static routes and policy may incorrectly delete rules created by u2o and egress-gateway. This can be auto recover before because vpc will enqueue all subnets when updated.
Fix #6235
Made with Cursor