fix localnet port should not be static "patch-localnet."#6244
fix localnet port should not be static "patch-localnet."#6244
Conversation
Signed-off-by: clyi <clyi@alauda.io>
|
Related Documentation No published documentation to review for changes on this repository. |
Summary of ChangesHello @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 introduces a crucial fix for handling local network service load balancing in environments with multiple subnets. By making the Highlights
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 fixes an issue by making the localnet port name dynamic based on the subnet name, propagating subnetName to the flow rule creation logic. No vulnerabilities were found during the SAST reconnaissance of pkg/daemon/controller_linux.go and pkg/daemon/flow_rules_linux.go. A suggestion is made to refactor the getPortID function to improve code clarity by removing an unused parameter.
pkg/daemon/flow_rules_linux.go
Outdated
| func (c *Controller) getPortID(bridgeName, portName string) (int, error) { | ||
| if c.ovsClient == nil { | ||
| return 0, errors.New("ovs client not initialized") | ||
| ofportStr, err := ovs.Get("Interface", portName, "ofport", "", true) | ||
| if err != nil { | ||
| return 0, fmt.Errorf("failed to get ofport for interface %s: %w", portName, err) | ||
| } | ||
|
|
||
| portInfo, err := c.ovsClient.OpenFlow.DumpPort(bridgeName, portName) | ||
| portID, err := strconv.Atoi(strings.TrimSpace(ofportStr)) | ||
| if err != nil { | ||
| return 0, fmt.Errorf("failed to dump port %s on bridge %s: %w", portName, bridgeName, err) | ||
| return 0, fmt.Errorf("failed to parse ofport %q: %w", ofportStr, err) | ||
| } | ||
| return portInfo.PortID, nil | ||
|
|
||
| return portID, nil | ||
| } |
There was a problem hiding this comment.
The bridgeName parameter is unused in this function after the refactoring. It should be removed from the function signature and its call sites in AddOrUpdateUnderlaySubnetSvcLocalFlowCache to improve code clarity.
| func (c *Controller) getPortID(bridgeName, portName string) (int, error) { | |
| if c.ovsClient == nil { | |
| return 0, errors.New("ovs client not initialized") | |
| ofportStr, err := ovs.Get("Interface", portName, "ofport", "", true) | |
| if err != nil { | |
| return 0, fmt.Errorf("failed to get ofport for interface %s: %w", portName, err) | |
| } | |
| portInfo, err := c.ovsClient.OpenFlow.DumpPort(bridgeName, portName) | |
| portID, err := strconv.Atoi(strings.TrimSpace(ofportStr)) | |
| if err != nil { | |
| return 0, fmt.Errorf("failed to dump port %s on bridge %s: %w", portName, bridgeName, err) | |
| return 0, fmt.Errorf("failed to parse ofport %q: %w", ofportStr, err) | |
| } | |
| return portInfo.PortID, nil | |
| return portID, nil | |
| } | |
| func (c *Controller) getPortID(portName string) (int, error) { | |
| oftportStr, err := ovs.Get("Interface", portName, "ofport", "", true) | |
| if err != nil { | |
| return 0, fmt.Errorf("failed to get ofport for interface %s: %w", portName, err) | |
| } | |
| portID, err := strconv.Atoi(strings.TrimSpace(ofportStr)) | |
| if err != nil { | |
| return 0, fmt.Errorf("failed to parse ofport %q: %w", ofportStr, err) | |
| } | |
| return portID, nil | |
| } |
Pull Request Test Coverage Report for Build 21575060506Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
* fix localnet port Signed-off-by: clyi <clyi@alauda.io>
* fix localnet port Signed-off-by: clyi <clyi@alauda.io>
* fix localnet port Signed-off-by: clyi <clyi@alauda.io>
Pull Request
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes
Fixes #(issue-number)