-
Notifications
You must be signed in to change notification settings - Fork 147
fix(ipsec): resolve golint warnings and remove name stuttering #1569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Welcome @shivansh-gohem! It looks like this is your first PR to kmesh-net/kmesh 🎉 |
Summary of ChangesHello @shivansh-gohem, 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 significantly improves the code quality and adherence to Go best practices within the IPsec controller logic. The primary goal was to resolve Highlights
🧠 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 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. Code now shines so bright, Stutter gone, names now clear, Linting makes it right. Footnotes
|
e9500e9 to
a7daab3
Compare
There was a problem hiding this 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 resolves golint warnings and improves code quality by removing name stuttering and adding documentation, which aligns with Go best practices. The changes are clear and well-executed. I've included a couple of suggestions to enhance error handling, making the controller more robust by preventing silent failures.
| func (c *Controller) deleteKNIMapCIDR(remoteCIDR string, mapfd *ebpf.Map) { | ||
| kniKey, err := c.generalKNIMapKey(remoteCIDR) | ||
| if err != nil { | ||
| return | ||
| } | ||
| _ = mapfd.Delete(kniKey) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function deleteKNIMapCIDR silently fails by returning early if generalKNIMapKey returns an error, and it ignores the error from mapfd.Delete. This can lead to stale entries in the eBPF map if deletion fails, which could cause incorrect networking behavior. The function should return an error to allow the caller to handle failures appropriately. You will need to update the call site in handleKNIDelete to handle the returned error, for example by logging it.
| func (c *Controller) deleteKNIMapCIDR(remoteCIDR string, mapfd *ebpf.Map) { | |
| kniKey, err := c.generalKNIMapKey(remoteCIDR) | |
| if err != nil { | |
| return | |
| } | |
| _ = mapfd.Delete(kniKey) | |
| } | |
| func (c *Controller) deleteKNIMapCIDR(remoteCIDR string, mapfd *ebpf.Map) error { | |
| kniKey, err := c.generalKNIMapKey(remoteCIDR) | |
| if err != nil { | |
| return err | |
| } | |
| return mapfd.Delete(kniKey) | |
| } |
|
Thanks for the review! You are right that the error handling here is missing. However, since this PR focuses strictly on linting and renaming (to fix #1475), I prefer not to change the function signature or logic right now. This avoids "scope creep" and prevents breaking the reflection-based tests in ipsec_controller_test.go. I can address the error handling in a separate, follow-up PR |
7ec502e to
ce55d1c
Compare
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
ce55d1c to
5df8347
Compare
LiZhenCheng9527
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what the point is in you making these changes.
config/kmesh_marcos_def.h
Outdated
| * current container based on the bpf_get_netns_cookie auxiliary function. | ||
| */ | ||
| #define MDA_LOOPBACK_ADDR 1 | ||
| #define MDA_LOOPBACK_ADDR 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies. These changes were automatically generated by the build script based on my local kernel environment and were included by mistake. I will revert the file so that PR will now only contain the intended linting fixes!
5df8347 to
28b9382
Compare
Signed-off-by: Shivansh Sahu <sahushivansh142@gmail.com>
28b9382 to
cacd85a
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
|
||
| type IPSecController struct { | ||
| // Controller manages the IPsec configuration and synchronization for Kmesh. | ||
| type Controller struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have some confusion. Why is this change needed? Is there something wrong with the name IPSecController?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The renaming from IPSecController to Controller addresses a golint warning regarding "stuttering."
Since this struct resides within the ipsec package, Go naming conventions suggest avoiding the repetition of the package name in the type name.
- Before:
ipsec.IPSecController(Redundant repetition) - After:
ipsec.Controller(Clean and idiomatic)
This change aligns the codebase with standard Go style guidelines without altering any logic.
|
/cc @LiZhenCheng9527 |
This PR resolves golint warnings in
pkg/controller/encryption/ipsec/ipsec_controller.goto improve code quality and comply with Go best practices.Changes:
IPSecControllertoControllerandNewIPsecControllertoNewController. Since this resides in theipsecpackage, usage becomesipsec.Controllerinstead of the repetitiveipsec.IPSecController.ClusterId->ClusterIDandPodIp->PodIPto match Go naming conventions.NewController,Run,Stop,CleanAllIPsec).ipsec_controller_test.goandpkg/controller/controller.goto reflect the renaming changes.Verification:
Ran
golangci-lint run --build-tags=linux pkg/controller/encryption/ipsec/...locally. Verified that all linting errors (typecheck and style) related to this controller are resolved.Fixes #1475