fix issue 5167: Add Finalizer when create snat#5170
fix issue 5167: Add Finalizer when create snat#5170QEDQCD wants to merge 5 commits intokubeovn:masterfrom
Conversation
Signed-off-by: liwenjian <liwenjian@tfcloud.com>
Signed-off-by: liwenjian <liwenjian@tfcloud.com>
There was a problem hiding this comment.
Hello @QEDQCD, 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!
Summary of Changes
This pull request addresses issue #5167 by adding a finalizer when creating a SNAT (Source Network Address Translation). The change modifies pkg/controller/vpc_nat_gw_nat.go to ensure the KubeOVNControllerFinalizer is added to the iptablesSnat object during creation. This finalizer helps manage the lifecycle of the SNAT resource and prevents premature deletion before associated resources are cleaned up.
Highlights
- Bug Fix: Addresses issue #5167 by ensuring a finalizer is added when creating SNAT resources.
- Finalizer Management: Adds the
KubeOVNControllerFinalizertoiptablesSnatobjects to control their deletion.
Changelog
- pkg/controller/vpc_nat_gw_nat.go
- Replaces the removal of the finalizer with the addition of the
KubeOVNControllerFinalizerto theiptablesSnatobject in thehandleDelIptablesSnatFinalizerfunction. Line 964 was changed fromcontrollerutil.RemoveFinalizertocontrollerutil.AddFinalizer.
- Replaces the removal of the finalizer with the addition of the
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 is currently in preview and 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 to provide feedback.
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.
A finalizer's gentle hand,
Guides resources across the land.
No premature deletion,
A managed completion,
Ensuring states correctly stand.
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.
Code Review
The pull request aims to fix issue 5167 by adding a finalizer when creating a snat. The change involves modifying the handleDelIptablesSnatFinalizer function to add the KubeOVNControllerFinalizer instead of removing the deprecated and current finalizers. This ensures that the finalizer is present during snat creation.
Summary of Findings
- Incorrect Finalizer Handling: The code in
handleDelIptablesSnatFinalizeris adding a finalizer instead of removing it, which is counterintuitive to the function's name and purpose. This could lead to unexpected behavior during deletion.
Merge Readiness
The pull request contains a critical error in the finalizer handling logic. The handleDelIptablesSnatFinalizer function is adding a finalizer instead of removing it. This needs to be corrected before merging. I am unable to approve this pull request, and recommend that it not be merged until the critical issue is addressed.
| controllerutil.AddFinalizer(newIptablesSnat, util.Kub | ||
| eOVNControllerFinalizer) |
There was a problem hiding this comment.
This line is adding the finalizer instead of removing it. The function handleDelIptablesSnatFinalizer should be removing the finalizer, not adding it. This is likely a copy/paste error from the add finalizer function, and needs to be corrected to ensure proper deletion of the SNAT rule. This is a critical issue as it prevents the SNAT rule from being properly deleted, which can lead to resource leaks and other problems.
controllerutil.RemoveFinalizer(newIptablesSnat, util.KubeOVNControllerFinalizer)47b195e to
89a9fdd
Compare
| newIptablesSnat := cachedIptablesSnat.DeepCopy() | ||
| controllerutil.RemoveFinalizer(newIptablesSnat, util.DepreciatedFinalizerName) | ||
| controllerutil.RemoveFinalizer(newIptablesSnat, util.KubeOVNControllerFinalizer) | ||
| controllerutil.AddFinalizer(newIptablesSnat, util.KubeOVNControllerFinalizer) |
There was a problem hiding this comment.
感觉有点不对劲:上面的 handleAddIptablesSnatFinalizer 是删除 finalizer,这里的 handleDelIptablesSnatFinalizer 是添加 finalizer。
|
PRs go stale after 60d of inactivity. Please comment or re-open the PR if you are still working on this PR. |
Pull Request
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes
Fixes #(5167)